gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:23:19 24 4
gpt4 key购买 nike

在我的一个 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com