我有一个非常简单的方法。但是在该方法中,UIAlertView 不会运行....这是我的方法:
-(void)post_result {
NSLog(@"Post Result");
post_now.enabled = YES;
[active stopAnimating];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Success" message:@"You're post has been successfully uploaded." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alertView show];
success_post_facebook = 0;
success_post_youtube = 0;
success_post_googleplus = 0;
success_post_tumblr = 0;
success_post_twitter = 0;
NSLog(@"Post Result END");
}
奇怪的是,UIAlertView 之前和之后的代码都会在这个方法中运行……所以到底是哪里错了??
感谢您的宝贵时间。
最佳答案
您很可能不是在主线程上调用 UIAlertView。要让它在主线程上运行,只需像这样使用主调度队列。
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Success" message:@"You're post has been successfully uploaded." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alertView show];
});
关于ios - 方法未运行 - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23344749/