Iphone UIImagePickerController:模式和推送模式

Iphone UIImagePickerController:模式和推送模式,iphone,objective-c,uiimagepickercontroller,Iphone,Objective C,Uiimagepickercontroller,我今天看到一种奇怪的行为。我试图从一个名为viewcontroller的BloodWingViewController子类的viewcontroller中打开uiimagepickercontroller。以下是显示选择器的代码: if (self.picker == nil) { [SVProgressHUD showWithStatus:@"Loading picker..."]; dispatch_queue_t concurrentQueue = dispatc

我今天看到一种奇怪的行为。我试图从一个名为viewcontroller的BloodWingViewController子类的viewcontroller中打开uiimagepickercontroller。以下是显示选择器的代码:

if (self.picker == nil) {   

    [SVProgressHUD showWithStatus:@"Loading picker..."];

    dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

    dispatch_async(concurrentQueue, ^{

        self.picker = [[[UIImagePickerController alloc] init] autorelease];
        self.picker.delegate = self;
        self.picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        self.picker.allowsEditing = NO;    

        dispatch_async(dispatch_get_main_queue(), ^{
            [self.navigationController presentModalViewController:picker animated:YES];    
            [SVProgressHUD dismiss];
        });

    });        

}  else {        
    [self.navigationController presentModalViewController:picker animated:YES];    
} 
上面的代码工作非常好,没有问题。我看到的奇怪的事情是,如果我通过push-seague进入这个所谓的BllodWingViewController并尝试打开选择器,它就会工作。但若我通过modal seague再次进入所谓的BllodWingViewController并尝试打开选择器,那个么它就根本不起作用了。没有捡拾器打开。你能解释一下这背后的原因吗?以及如何克服这个问题,因为我必须从viewcontroller中打开选择器,该选择器已通过模态seague连接执行

对不起,如果我的英语让你困惑的话:p

编辑:

}

@界面EditStudentViewController:UIViewController{ UIImagePickerController*选择器; }

IBActiononPhotoPickerClick:idsender; @属性保留,非原子UIImagePickerController*选择器

@结束

现在,当我使用push-segue连接访问EditStudentViewController时,onPhotoPickerClick正在工作,这意味着出现了photolibary,我可以选择图像。但当我从上一个viewcontroller转到EditStudentViewController时,photolibary根本就没有出现


谢谢。

您可能将代理设置错误,但很难说。请提供更多详细信息,说明您是如何准确地向选取者演示的,以及发生了什么和没有发生什么。pickerlibrary的图像不会显示。当我按下按钮显示UIImagePickerController时,会调用上面的代码。为什么在演示代码中使用picker而不是self.picker?picker本身就是这个viewcontroller子类的成员,我从中调用这个东西。那么self.picker/picker指的是相同的权利?我的问题是,为什么这个viewcontroller是使用push-segue连接显示的,而不是使用modal-segue连接显示的。我已经编辑了这篇文章。上面的代码是有效的。
- (IBAction)onPhotoPickerClick:(id)sender {
if (self.picker == nil) {   

    [SVProgressHUD showWithStatus:@"Loading picker..."];

    dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

    dispatch_async(concurrentQueue, ^{

        self.picker = [[[UIImagePickerController alloc] init] autorelease];
        self.picker.delegate = self;
        self.picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        self.picker.allowsEditing = NO;         

        dispatch_async(dispatch_get_main_queue(), ^{
            [self.navigationController presentModalViewController:picker animated:YES];    
            [SVProgressHUD dismiss];
        });

    });        

}  else {        
    [self.navigationController presentModalViewController:picker animated:YES];    
} 
#import <UIKit/UIKit.h>