2

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

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

但是,我收到以下警告并且它没有被转移:

警告:在演示过程中尝试演示!

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

5 回答 5

2

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

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

在此处输入图像描述

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

-(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];
}
于 2013-08-31T22:29:24.453 回答
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];
}
于 2012-12-16T08:19:50.690 回答
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;

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

于 2012-12-16T08:21:02.417 回答
1

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

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

编辑:我添加了 if 语句,现在试试。

于 2012-12-16T09:51:34.367 回答
1

问题是在 TakePhotoViewController 中,我有:

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

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

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

于 2012-12-16T13:17:05.923 回答