Xcode 8 iOS9 UIAlertController文本消失。 在从Xcode7迁移到Xcode8之前,在iOS9上运行应用程序时没有任何问题。
有没有人有这个问题?
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@“mile”message:nil preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:getLocalizationString(@"cancel") style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UITextFieldTextDidChangeNotification object:nil];
}];
[alertController addAction:cancelAction];
@weakify(alertController);
@weakify(self);
UIAlertAction *okAction = [UIAlertAction actionWithTitle:getLocalizationString(@"ok") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UITextFieldTextDidChangeNotification object:nil];
@strongify(alertController);
@strongify(self);
UITextField *textField = alertController.textFields.firstObject;
self.totalMileage = textField.text;
self.mileageLabel.text = self.totalMileage;
if (self.start2DriveDateTime&&![self.start2DriveDateTime isEqualToString:@""]) {
[self getRecommendMaintenanceList];
}
}];
okAction.enabled = (self.totalMileage&&![self.totalMileage isEqualToString:@""]);
[alertController addAction:okAction];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField){
@strongify(self);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(alertTextFieldDidChange:) name:UITextFieldTextDidChangeNotification object:textField];
textField.placeholder = @"mile";
textField.keyboardType =UIKeyboardTypeNumberPad;
textField.text = self.totalMileage;
textField.delegate = self;
}];
[self.navigationController presentViewController:alertController animated:YES completion:nil];