我有一个iPhone应用程序发送电子邮件。如果“To:”地址未设置,则显示警报(UIAlertView)。目前,我不检查用户点击OK,我只是继续我的快乐! :d如何在ViewController已经有委托时设置委托?
警觉攻确定,当我收到以下错误:
wait_fences:未能收到回复:10004003
我相信这是因为我不处理的攻丝的确定,它仍然显示应用程序正在做其他事情时。因此,在SO和谷歌做了一些研究之后,看来我必须有这样的:
- (void) Alert: (NSString *) title andData: (NSString *) errorMsg {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: title
message: errorMsg
delegate:nil
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
[alert show];
return;
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"button was pressed");
}
我的问题是,我无法弄清楚如何建立委托这一点。我已经有一个委托:
@interface ReportViewController : UIViewController <UIWebViewDelegate> {
如何设置委托所以OK按钮的自来水进行处理,从而消除了错误?
我会推荐真正理解委托设计模式,而不是仅仅解决这个问题。这是你理解最有用的东西之一。 https://developer.apple.com/library/mac/#documentation/cocoa/conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html – rooster117