相关疑难解决方法(0)

presentViewController:animated:YES视图在用户再次点击之前不会出现

我有一些奇怪的行为presentViewController:animated:completion.我所做的实际上是一个猜谜游戏.

我有一个UIViewController(frequencyViewController)包含一个UITableView(frequencyTableView).当用户点击包含正确答案的questionTableView中的行时,视图(correctViewController)应该是实例化的,并且其视图应该从屏幕底部向上滑动,作为模态视图.这告诉用户他们有正确的答案并重置其背后的frequencyViewController,准备好接下来的问题.按下按钮时,correctViewController被解除以显示下一个问题.

这一切都可以正常工作,只要presentViewController:animated:completion有正确的ViewController视图就会立即出现animated:NO.

如果我设置animated:YES,则初始化correctViewController并进行调用viewDidLoad.但是viewWillAppear,viewDidAppear并且presentViewController:animated:completion不会调用完成块.该应用程序只是坐在那里仍然显示frequencyViewController,直到我再次点击.现在,调用viewWillAppear,viewDidAppear和完成块.

我调查了一下,并不只是另一个水龙头会导致它继续下去.看起来如果我倾斜或摇动我的iPhone,这也可能导致它触发viewWillLoad等.就像它正在等待任何其他位用户输入才会进展.这发生在真正的iPhone和模拟器中,我通过向模拟器发送shake命令证明了这一点.

我真的不知道该怎么做......我真的很感激任何人都可以提供帮助.

谢谢

这是我的代码.这很简单......

这是questionViewController中的代码,它充当questionTableView的委托

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    if (indexPath.row != [self.frequencyModel currentFrequencyIndex])
    {
        // If guess was wrong, then mark the selection as incorrect
        NSLog(@"Incorrect Guess: %@", [self.frequencyModel frequencyLabelAtIndex:(int)indexPath.row]);
        UITableViewCell *cell = [self.frequencyTableView cellForRowAtIndexPath:indexPath];
        [cell setBackgroundColor:[UIColor colorWithRed:240/255.0f green:110/255.0f blue:103/255.0f alpha:1.0f]];            
    }
    else
    {
        // If guess was correct, show correct view
        NSLog(@"Correct …
Run Code Online (Sandbox Code Playgroud)

uiviewcontroller ios

90
推荐指数
3
解决办法
2万
查看次数

标签 统计

ios ×1

uiviewcontroller ×1