如何呈现UIMenuController和UIAlertController?

时间:2018-02-12 13:45:27

标签: ios objective-c uialertcontroller uimenucontroller

我正在尝试下一个方式:

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提供alertcontroller。

像这样: enter image description here

1 个答案:

答案 0 :(得分:1)

您的问题与 void Update() { Movement(); } void Movement() { physicPlayer.velocity = Vector2.zero; if (Input.GetKey(KeyCode.LeftArrow) && transform.position.x >= -moveRangeX) physicPlayer.velocity = new Vector2(-moveSpeed, physicPlayer.velocity.y); if (Input.GetKey(KeyCode.RightArrow) && transform.position.x <= moveRangeX) physicPlayer.velocity = new Vector2(moveSpeed, physicPlayer.velocity.y); if (Input.GetKey(KeyCode.UpArrow) && transform.position.y <= moveRangeY) physicPlayer.velocity = new Vector2(physicPlayer.velocity.x, moveSpeed); if (Input.GetKey(KeyCode.DownArrow) && transform.position.y >= -moveRangeY) physicPlayer.velocity = new Vector2(physicPlayer.velocity.x, -moveSpeed); } 您必须考虑UIMenuController必须实施UIView方法返回canBecomeFirstResponder

的问题有关
YES

enter image description here