我想阻止UIAlertController解雇.
我有一个UIAlertAction只是在UIAlertTextField中添加一个字符串,但是,一旦点击它就会解除视图控制器[不需要的].我已经尝试添加一个不需要的结果的NSNotification.
UIAlertAction *pasteMessage = [UIAlertAction actionWithTitle:@"Paste Message" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
UITextField *textField = alertC.textFields.firstObject;
textField.text = [textField.text stringByAppendingString:[NSString stringWithFormat:@"%@", copiedString]];
}];
Run Code Online (Sandbox Code Playgroud)
我也尝试过将pasteMessage设置为:
[alertC canPerformAction:@selector(dismissViewControllerAnimated:completion:) withSender:pasteMessage];
-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
UIAlertController *alertController = (UIAlertController *)self.presentedViewController;
UIAlertAction *paste = alertController.actions.firstObject;
if (paste) {
flag = NO;
} else {
flag = YES;
}
}
Run Code Online (Sandbox Code Playgroud)
编辑,我不打算阻止攻击UIAlertAction我希望防止UIAlertController在点击上述行动时解雇.无论如何都可以启用/禁用该操作,但我的目标是UITextField通过按动作简单地将复制的消息粘贴到该动作中(因此我不希望它被解除)
我也意识到设置BOOL dismissViewControllerAnimated:只是将它设置为不动画视图控制器解雇,我不希望它暗示它是为了停止实际的解雇过程.简单地提供我尝试过与我的目标相关的事情.我还尝试在选择pasteMessage时使用复制的消息自动填充新的 textField 时会出现一个新的 ,它可以工作,但我觉得它太可能无法完成.UIAlertController UIAlertControllers