iPhone - 在UIImagePickerController上显示模态视图

时间:2011-10-16 13:39:58

标签: iphone ios cocoa-touch uinavigationcontroller uiimagepickercontroller

我有一个UIImagePickerController,在加载时,我想在modalView中显示免责声明。

- (void) viewDidLoad 
{
    self.picker = [[UIImagePickerController alloc] init];
    self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
    self.picker.delegate = self;

    [self presentModalViewController:self.picker animated:NO];
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];

    DisclaimerController* disclaimer = [[DisclaimerController alloc] init];  // Loads the Xib inside the init method
    UINavigationController* controller = [[UINavigationController alloc] initWithRootViewController:disclaimer];
    [self.navigationController presentModalViewController:controller animated:YES];
}

但它没有出现。

我不想在免责声明显示或稍后显示时解雇选择器,因为有一些处理需要一些时间,而且用户阅读免责声明的时间会阻止他在关闭后等待太长时间免责声明。

1 个答案:

答案 0 :(得分:1)

我会使用AlertView来解决它。

但是如果你更喜欢使用你的方法,也许这就可以了。

试试这个:

- (void) showModalDisclaimer {
        DisclaimerController* disclaimer = [[DisclaimerController alloc] init];  
        // Loads the Xib inside the init method
        UINavigationController* controller = [[UINavigationController alloc] 
                                          initWithRootViewController:disclaimer];
        [self.picker presentModalViewController:controller animated:YES]; 
        // notice self.picker
}

- (void) viewDidLoad 
{
    self.picker = [[UIImagePickerController alloc] init];
    self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
    self.picker.delegate = self;

    [self presentModalViewController:self.picker animated:NO];
    [[UIApplication sharedApplication] setStatusBarHidden:NO   
                       withAnimation:UIStatusBarAnimationNone];
    [self performSelector:@selector(showModalDisclaimer) withObject:nil afterDelay:0.1];
}