objective-c - 为什么我的方法在 iPhone/iPod 上被调用两次,但在 iPad 上却没有?

标签 objective-c ios cocoa-touch uinavigationcontroller

在我的一个 View Controller 中,单击按钮后会调用以下函数,以便我可以进行一些初始化并弹出当前 View (ResultViewController) 并显示上一个 View (GameViewController)。

- (IBAction)PlayNextList:(id)sender {
    NSInteger index = [[[GameStore defaultStore] allLists] indexOfObjectIdenticalTo:[[GameStore defaultStore] selectedList] ];

    if(index == [[[GameStore defaultStore] allLists] count]-1)
    {
        index = 0;
    }
    index++;
    [[GameStore defaultStore] setSelectedList:[[[GameStore defaultStore] allLists] objectAtIndex:index]];
    [[GameStore defaultStore] resetGame]; 

    [[GameStore defaultStore] createResult];
    NSLog(@"Press Next List");
    NSLog(@"%@",[[[[GameStore defaultStore] allLists] objectAtIndex:index] label]);
    [[self navigationController] popViewControllerAnimated:YES];

}

在 iPhone/iPod 上,我注意到 [[GameStore defaultStore] createResult]; 被调用了两次,但在 iPad 上只被调用了一次。

在尝试弄清楚为什么它被调用两次后,我发现第二次调用发生在 GameViewControllerviewWillAppearviewDidAppear 之间.

知道为什么会发生这种情况吗?

最佳答案

确保检查连接检查器中是否有触发激活 PlayNextList 的事件,特别是如果您有适用于 iPhone 和 iPad 的不同 NIB 文件,并确保该事件不会两次连接到同一方法。

关于objective-c - 为什么我的方法在 iPhone/iPod 上被调用两次,但在 iPad 上却没有?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9416619/

相关文章:

objective-c - NSWindow 阴影轮廓

objective-c - 计算 Cocoa-Touch 中调用方法的次数?

ios - Arc4随机 float ?

c - iOS:将对象添加为属性监听器时,是否必须在释放对象之前将监听器设置为 "unregister"?

ios - NSDateFormatter dateFromString 无

objective-c - UIImagePickerController 不会录制视频

objective-c - 自定义 iPhone 应用程序任务栏

iphone - UIImageView 旋转不正确?

ios - iOS 8 的 ActionSheetPicker 替代品

iphone - UIImagePNGRepresentation问题?/图像旋转90度