我正在尝试以编程方式调用 UIAlertView 的委托方法。这是代码:
if([vc respondsToSelector:@selector(alertView:clickedButtonAtIndex:)]) {
// Manually invoke the alert view button handler
[(id <UIAlertViewDelegate>)vc alertView:nil
clickedButtonAtIndex:0];
}
它在 iOS5.0 上运行良好,但在 iOS6.0 上无法运行,欢迎提出意见或建议 :)
这是详细的完整方法:
TWTweetComposeViewController *vc = [[[TWTweetComposeViewController alloc] init]autorelease];
// Settin The Initial Text
[vc setInitialText:status];
[vc setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
if(result == TWTweetComposeViewControllerResultDone) {
NSLog(@"Tweeted Sucessfully");
}
}];
if([delegate isKindOfClass:[UIViewController class]]){
[(UIViewController *)delegate presentModalViewController:vc animated:YES];
}
//alertView:clickedButtonAtIndex:
if([vc respondsToSelector:@selector(alertView:clickedButtonAtIndex:)]) {
// Manually invoke the alert view button handler
[(id <UIAlertViewDelegate>)vc alertView:nil
clickedButtonAtIndex:0];
}
}