【发布时间】:2017-05-12 01:56:39
【问题描述】:
如何将 textview 值传递给 alertController textFields 块?
我有 textview 组件调用“myTextView”
@property (weak, nonatomic) IBOutlet UITextView *myTextView
我在下面设置了警报控制器:
myAlertController = [UIAlertController alertControllerWithTitle:@"title" message:@"pass the value in alertcontroller" preferredStyle: UIAlertControllerStyleAlert];
myAlertControllerOKAction = [UIAlertAction actionWithTitle:@"sure" style:UIAlertActionStyleDefault
handler:nil];
[myAlertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.keyboardType = UIKeyboardTypeDefault;
textField.text = [self.myTextView.text stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
}];
[myAlertController addAction: myAlertControllerOKAction];
但我在 myAlertController 块中设置了 myTextView.text,
textField.text = [self.myTextView.text stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
}];
它会显示
在此块中强烈捕获“自我”可能会导致保留周期
如何获取警报控制器块中的 textview 值以供文本字段使用?
【问题讨论】:
标签: ios objective-c objective-c-blocks