我需要從庫中拍照並將其設置爲UIImageView
。UINavigationController在UIImagePickerController上不起作用?
我有一類是UIViewController的它實現了代表UINavigationControllerDelegate
和UIImagePickerControllerDelegate
在我的代碼我已經實現了委託方法,
-(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]];
}
問題是導航欄項目Cancel
和Photos
按鈕的功能不行。
有人可以指出我是否缺少代碼中的任何東西嗎?
我的截圖 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;
有你加入 –
@Bhumeshwerkatre是的,我有 – erdemgc
[自presentViewController:pickerController動畫:是完成:零]嘗試像這樣 – TamilKing