【问题标题】:UIAlertview won't log resultUIAlertview 不会记录结果
【发布时间】:2013-10-02 10:36:12
【问题描述】:

如果用户在我的alertView 上按下 OK,我想记录,但它什么也没做...这是我的检查:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) { NSLog(@"user pressed OK"); }
}

也在我的@interface:

@interface FirstViewController : UIViewController<UIWebViewDelegate, UIAlertViewDelegate>

这是我的alertView:

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oeps..."
                                            message:@"This is just a random message."
                                            delegate:nil
                                            cancelButtonTitle:@"OK"
                                            otherButtonTitles:nil];
[alertView show];

有人看到问题了吗?我试图在if buttonIndex 之外做一个NSLog 但这也不会被记录..

谢谢

【问题讨论】:

    标签: ios objective-c uialertview uialertviewdelegate


    【解决方案1】:

    将您的代理分配为自己,而不是委托为 nil

    【讨论】:

      【解决方案2】:

      使用以下内容:

      UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oeps..."
                                              message:@"This is just a random message."
                                              delegate:self
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
      [alertView show];
      

      【讨论】:

        【解决方案3】:

        检查您的委托,您将委托传递给 nil。将它传递给 self 这就是发生这种情况的原因......

        喜欢这个

        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oeps..."
                                                    message:@"This is just a random message."
                                                    delegate:self
                                                    cancelButtonTitle:@"OK"
                                                    otherButtonTitles:nil];
        [alertView show];
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多