gpt4 book ai didi

ios - 如何同时呈现 UIMenuController 和 UIAlertController?

转载 作者:行者123 更新时间:2023-11-29 11:36:44 24 4
gpt4 key购买 nike

我正在尝试下一种方式:

Message *message = self.messagesArray[indexPath.row];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:LocalizedString(@"FirstAction")
message:@""
preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *editMessage = [UIAlertAction actionWithTitle:LocalizedString(@"SecondAction") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}];
[alertController addAction:editMessage];
UIAlertAction *forwardMessage = [UIAlertAction actionWithTitle:LocalizedString(@"ThirdAction") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}];
[alertController addAction:forwardMessage];
UIAlertAction *deleteMessage = [UIAlertAction actionWithTitle:LocalizedString(@"DeleteMessage") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}];
[alertController addAction:deleteMessage];
[self setSourceViewForAlertController:alertController];
[self presentViewController:alertController animated:YES completion:nil];
[self createMenuForMessage:message];
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];

因此,我的目标是同时为 UICollectionViewCell 和 UIMenuController 提供警报 Controller 。

像这样: enter image description here

最佳答案

你的问题与你在哪里显示你的 UIMenuController 有关

- (IBAction)action:(id)sender {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@""
message:@""
preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *editMessage = [UIAlertAction actionWithTitle:@"Edit" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}];
[alertController addAction:editMessage];
UIAlertAction *forwardMessage = [UIAlertAction actionWithTitle:@"Move" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}];
[alertController addAction:forwardMessage];
UIAlertAction *deleteMessage = [UIAlertAction actionWithTitle:@"Delete" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}];
[alertController addAction:deleteMessage];
[self presentViewController:alertController animated:YES completion:nil];
[[UIMenuController sharedMenuController] setTargetRect:self.view.bounds inView:self.view];
[[UIMenuController sharedMenuController] setArrowDirection:UIMenuControllerArrowDefault];
[[UIMenuController sharedMenuController] setMenuItems:@[[[UIMenuItem alloc]initWithTitle:@"test" action:@selector(didReceiveMemoryWarning)]]];
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
}

-(BOOL)canBecomeFirstResponder{
return true;
}

enter image description here

关于ios - 如何同时呈现 UIMenuController 和 UIAlertController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48747973/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com