且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在没有委托的情况下从UIAlertView完成块访问用户输入?

更新时间:2022-11-03 19:32:56

所以基本上你想要从中查看警报视图块。你可以这样做:

So basically you want to access the alert view from the block. You can do something like this:

__block __weak UIAlertView *alertViewWeak;
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Add"
                           message:@"Add New Asset Type"
                        completion:^(BOOL cancelled, NSInteger buttonIndex){
                            if (!cancelled) {

                                //call on completion of UISheetAction ???
                                NSLog(@"%@",[alertViewWeak textFieldAtIndex:0]);



                            }
                        }
                 cancelButtonTitle:@"Cancel"
                 otherButtonTitles:@"OK", nil];
alertViewWeak = alertView;
[alertView show];