【问题标题】:Xcode5 error : Warning attempt to present <View> on <OtherView> while presentation is in progressXcode5 错误:警告尝试在演示过程中在 <OtherView> 上显示 <View>
【发布时间】:2013-11-03 12:08:06
【问题描述】:

在为 iOS 制作应用程序方面,我仍然是个菜鸟,我不明白为什么我会遇到某个错误。对于我当前的项目,我正在尝试切换视图,但我无法让它工作,我也不明白为什么。我按照这个教程的按钮(http://www.youtube.com/watch?v=ph3XhJD8QAI)虽然教程较旧,但它仍然有效。我不得不编辑一些代码以确保它适用于 Xcode 5。每次我按下按钮切换视图时,我都会收到一条错误消息,上面写着“警告:尝试在 <0xc91a130>

    标签: ios iphone objective-c xcode xcode5


    【解决方案1】:

    在呈现另一个视图之前,您必须完全关闭一个视图。尝试:

    [self dismissViewControllerAnimated:YES completion: ^{
        SecondView *second = 
              [[SecondView alloc] initWithStyle:UITableViewStylePlain];
        controller.modalTransitionStyle = UITableViewStylePlain;
        [self presentViewController:second animated:YES completion:nil];
    }];
    

    【讨论】:

    • 我正在开发一个单一的视图应用程序,所以 Tableview 的东西在我的情况下并不能真正起作用。我还复制了您的确切代码,结果出现的错误比我最初开始时更多的错误
    • 对不起。我没有看到您正在使用情节提要。检查您是否调用了两次视图控制器,一次来自按钮,一次来自segue。
    • 不太清楚你的意思,你能澄清一下吗?对不起,我还是新手。我很确定我做对了......或者我认为
    • 好吧,我会尝试解释,但通常我不使用情节提要。在您的故事板中,您是否触发了从 SwitchViewButon 到新视图控制器的转场?如果是这样,我认为当您单击按钮时会触发 segue,但也会再次由于 IBAction。
    • 好的,我应该怎么做才能阻止这种情况发生?
    【解决方案2】:

    评论 switchview 的主体,并检查单击 switchview 时是否显示任何控制器。这看起来很傻,但可能有助于找出正在进行的控制器...我也没有使用到情节提要,所以..希望对您有所帮助

    【讨论】:

      【解决方案3】:
      - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
      
       // TODO: make this all threaded?
       // crop the image to the bounds provided
       img = [info objectForKey:UIImagePickerControllerOriginalImage];
       NSLog(@"orig image size: %@", [[NSValue valueWithCGSize:img.size] description]);
      
       // save the image, only if it's a newly taken image:
       if ([picker sourceType] == UIImagePickerControllerSourceTypeCamera) {
           UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
       }
      
       // self.image_View.image = img;
       // self.image_View.contentMode = UIViewContentModeScaleAspectFit;
      
      NSLog(@"Picker has returned");
      [self dismissViewControllerAnimated:YES
                               completion:^{
                                  ModalViewController *sampleView = [[ModalViewController alloc] init];
                                  [self presentModalViewController:sampleView animated:YES];
                               }];
      

      }

      【讨论】:

        猜你喜欢
        • 2015-12-04
        • 2013-10-15
        • 1970-01-01
        • 2012-12-03
        • 2012-11-18
        • 2014-06-12
        • 1970-01-01
        • 1970-01-01
        • 2014-04-24
        相关资源
        最近更新 更多