0
我幾乎閱讀了所有相關文章,但仍然無法取消警報。誰能幫忙?它不應該那麼難...UIAlertViewController的警報模式不能通過添加UIAlertAction來解除
P.S.在defaultAction的回調,我都嘗試:
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"ok...");
}];
和
NSLog(@"ok...");
兩個的運氣我的代碼的
:
#import "ViewController.h"
@interface ViewController()
@property (strong, nonatomic) UIAlertController *alert;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidAppear:(BOOL)animated {
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Reminder"
message:@""
preferredStyle:UIAlertControllerStyleAlert];
self.alert = alert;
self.alert.message = @"You just logged in. The tab will be refreshed";
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"webview is reloading...");
}];
}];
[self.alert addAction:defaultAction];
[self presentViewController:self.alert animated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
事實證明這是iOS模擬器的問題。它可以正常工作NSLog(@「ok ...」);設備上的解決方案現在向蘋果提交問題... – lkahtz
我投票結束這個問題作爲題外話,因爲這主要是來自Apple的一個bug。我將盡快與他們一起打開技術支持憑單。在我得到更多信息之前,我現在要關閉這個問題。 – lkahtz