0

我需要从库中拍照并将其设置为UIImageViewUINavigationController在UIImagePickerController上不起作用?

我有一类是UIViewController的它实现了代表UINavigationControllerDelegateUIImagePickerControllerDelegate

在我的代码我已经实现了委托方法,

-(void) addPhotoPressed: (id)sender 
{ 
    UIImagePickerController *pickerController = [[UIImagePickerController alloc] init]; 
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { 
     pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     pickerController.allowsEditing = YES; 
     pickerController.delegate = self; 
     [self presentViewController:pickerController animated:YES completion:NULL]; 
    } 
} 

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 
    [self dismissViewControllerAnimated:YES completion:NULL]; 

    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; 
    if (image == nil) 
     image = [info objectForKey:UIImagePickerControllerOriginalImage]; 
    // Do something with the image 
    [cardView setBackgroundColor:[UIColor colorWithPatternImage:image]]; 
} 

问题是导航栏项目CancelPhotos按钮的功能不行。

有人可以指出我是否缺少代码中的任何东西吗?

我的截图 http://i.stack.imgur.com/GqVW7.png

我.h文件中

@interface AlterDesignView : UIViewController <UINavigationControllerDelegate,  UIImagePickerControllerDelegate> 
{ 

    UIScrollView * mainScroll; 
    UILabel * cardTitle; 
    UIView * cardView; 
    UISlider *colorSlider; 
    UIButton *addPhoto; 
    UIButton *saveContinue; 


} 

@property(nonatomic,retain) UIScrollView *mainScroll; 
@property(nonatomic,retain) UILabel *cardTitle; 
@property(nonatomic,retain) UIView *cardView; 
@property(nonatomic,retain) UISlider *colorSlider; 
@property(nonatomic,retain) UIButton *addPhoto; 
@property(nonatomic,retain) UIButton *saveContinue; 
+0

有你加入

+0

@Bhumeshwerkatre是的,我有 – erdemgc

+0

[自presentViewController:pickerController动画:是完成:零]尝试像这样 – TamilKing

回答

0
UIImagePickerController *image_picker = [UIImagePickerController new]; 
    image_picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
    image_picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; 
    image_picker.delegate = self; 
    [self presentModalViewController:image_picker animated:YES]; 

的Tr1这样。这对我的工作......我希望它时便会对你有所帮助

+0

仍然不能正常工作 – erdemgc

+0

@erdemgc:我认为问题不在presentModalviewcontroller ..你分享你的代码我会检查并告诉你的问题 – TamilKing

+0

我已经分享了我的代码 – erdemgc

相关问题