图像选择器弹出窗口

时间:2012-07-12 03:02:35

标签: iphone ios xcode

AGImagePickerController *imagePickerController = [[AGImagePickerController alloc] initWithFailureBlock:^(NSError *error) {

    if (error == nil)
    {
        NSLog(@"User has cancelled.");
        [self dismissModalViewControllerAnimated:YES];
    } else
    {     
        NSLog(@"Error: %@", error);

        // Wait for the view controller to show first and hide it after that
        double delayInSeconds = 0.5;
        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
        dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            [self dismissModalViewControllerAnimated:YES];
        });
    }

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];

} andSuccessBlock:^(NSArray *info) {
    NSLog(@"Info: %@", info);
    [self dismissModalViewControllerAnimated:YES];

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
}];

popover = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
[popover presentPopoverFromRect:CGRectMake(0.0, 0.0, 400.0, 400.0) 
                         inView:self.view.window
       permittedArrowDirections:UIPopoverArrowDirectionAny 
                       animated:YES];

能够呈现它,但是,即使我更改它的大小仍然相同,当我按下DONE按钮时,它会删除我的View控制器而不是imagepicker。请帮忙。我把它呈现在popover中,因为我认为,这就是为什么它的速度慢,因为imagepicker应该与iPad的popover一起出现。

2 个答案:

答案 0 :(得分:1)

您是否正在实施AGImagePickerController委托?

- (void)agImagePickerController:(AGImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info;

在那里你可以解雇你的UIPopoverController

答案 1 :(得分:0)

调整大小以这种方式设置:

[popoverController setPopoverContentSize:CGSizeMake(1024, 500)];

然后在您使用的andSuccessBlock和其他部分:

[self dismissModalViewControllerAnimated:YES];

应该是

[popoverController dismissPopoverAnimated:YES];

这就是为什么ViewController被解雇或从视图中移除的原因,因为它被错误地解雇了。