我有一个可以发送电子邮件的 iPhone 应用程序。如果未设置“收件人:”地址,我会显示警报 (UIAlertView)。目前,我不检查用户是否点击“确定”,我只是继续我的快乐之路! :D
点击警报上的“确定”时出现以下错误:
wait_fences: failed to receive reply: 10004003
我相信这是因为我没有处理“确定”的点击,并且当应用程序正在执行其他操作时它仍然显示。因此,在对 SO 和 Google 进行了一些研究之后,看来我必须这样做:
- (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");
}
我的问题是我不知道如何为此设置委托(delegate)。我已经有一个代表了:
@interface ReportViewController : UIViewController <UIWebViewDelegate> {
如何设置委托(delegate)以便处理“确定”按钮的点击,从而消除错误?
最佳答案
在尖括号内,您可以提供以逗号分隔的协议(protocol)列表。
@interface ReportViewController : UIViewController <UIWebViewDelegate, UIAlertViewDelegate> {
现在您可以实现这两组方法了。并且不要忘记将警报 View 的委托(delegate)设置为 self
。
关于ios - 当 ViewController 已经有委托(delegate)时如何设置委托(delegate)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13167932/