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

相關問題