警告:在演示文稿正在进行时尝试在<takephotoviewcontroller>上显示<adjustphotoviewcontroller> </takephotoviewcontroller> </adjustphotoviewcontroller>

时间:2012-12-16 07:58:25

标签: iphone objective-c uiviewcontroller uistoryboardsegue overlay-view

我正在使用xcode 4.5.2并为相机按钮创建了我自己的OverlayViewController。

现在,当我的委托控制器 - TakePhotoViewController从OverlayViewController检索didFinishWithCamera操作时,我想将用户转移到AdjustPhotoViewController。

但是,我收到以下警告,但未被转移:

  

警告:尝试出现    正在进行演示!

- (void)didFinishWithCamera
{
    [[self.overlayViewController.imagePickerController presentingViewController] dismissViewControllerAnimated:YES completion:nil];
    [self performSegueWithIdentifier:@"fromTakeToAdjust" sender:self];    
}

5 个答案:

答案 0 :(得分:2)

实际上,根据我的经验,这与从同一个按钮调用segue和IBAction(调用segue)有关 - 检查Interface Builder中的连接检查器,看看你的按钮是否连接到两者。

在你的故事板中,它可能如下所示:

enter image description here

在您的代码中,它可能如下所示:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if([segue.identifier isEqualToString:@"pushToNewVC"]) {
        UIViewController *controller = (UIViewController *)segue.destinationViewController;
    }
}

=

- (IBAction)launchNew VC:(id)sender {
    [self performSegueWithIdentifier:@"pushToNewVC" sender:sender];
}

答案 1 :(得分:1)

您可以尝试这样做,为旧过渡完成和新过渡提供时间

通常0.3有效,但可根据需要进行调整

- (void)didFinishWithCamera
{
    [[self.overlayViewController.imagePickerController presentingViewController] dismissViewControllerAnimated:YES completion:nil];
    [self performSelector:@selector(showModel) withObject:nil afterDelay:0.3];
}

- (void)showModel {
    [self performSegueWithIdentifier:@"fromTakeToAdjust" sender:self];
}

答案 2 :(得分:1)

请使用以下代码进行叠加视图控制。

请与您核实代码。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  
    [self.window addSubview:self.view];
    [self.window makeKeyAndVisible];

    return YES;
}

在代码使用后的viewdidload事件中

- (void) viewDidLoad {
    self.picker = [[UIImagePickerController alloc] init];
    self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    self.picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;

    self.picker.showsCameraControls = NO;
    self.picker.wantsFullScreenLayout = YES;

    // Insert the overlay
    self.overlay = [[Customview alloc] initWithNibName:@"Customview" bundle:nil];
    self.overlay.pickerRef = self.picker;
    self.picker.cameraOverlayView = self.overlay.view;

    [self presentModalViewController:self.picker animated:NO];
}

在代码中使用

的视图.h方法
   @interface CameraController : UIViewController {
        UIImagePickerController* __picker;
        Customview* __overlay;
    }

@property (nonatomic, retain) UIImagePickerController* picker;
@property (nonatomic, retain) Customview* overlay;

希望上面的代码对您有所帮助。

答案 3 :(得分:1)

Odelya,您应该在完成块中执行一些动画(在此cae控制器解雇中)后执行的UI操作!它实际上是为这些目的而创建的。像这样编辑你的代码:

- (void)didFinishWithCamera
{
    if(![[self.overlayViewController.imagePickerController presentingViewController] isBeingDismissed]) {
        [[self.overlayViewController.imagePickerController presentingViewController] dismissViewControllerAnimated:YES completion:^ {
            [self performSegueWithIdentifier:@"fromTakeToAdjust" sender:self];
        }];
    }   
}

编辑:我已经添加了if语句,请立即尝试。

答案 4 :(得分:1)

问题是在TakePhotoViewController中,我有:

- (void)viewDidAppear:(BOOL)animated{
   [self openImagePicker];
}

这会导致打开图像选择器,同时尝试将其关闭。

我添加了一个标志来检查它。