這是我的代碼,我不知道它有什麼問題。我擔心ImagePickerController方法。它有什麼問題嗎?我聲明瞭圖像視圖的屬性,我只是希望ViewController轉換到我的EditViewController,但是在選擇了圖像之後,它讓我回到ViewController而不是編輯視圖控制器。 ViewController.h:試圖讓方法被聲明後出現視圖控制器
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface ViewController : UIViewController <UIImagePickerControllerDelegate ,
UINavigationControllerDelegate ,ADBannerViewDelegate>
-(IBAction)GoToEdit:(id)sender;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (strong,nonatomic) UIImage *chosenImage;
@property (strong,nonatomic) UIImagePickerController *imagePicker;
@end
ViewController.m
- (IBAction)chooseImage:(id)sender {
self.imagePicker = [[UIImagePickerController alloc] init];
self.imagePicker.delegate = self;
[self.imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:self.imagePicker animated:YES completion:nil];
}
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:
(NSDictionary *)info{
self.chosenImage = info[UIImagePickerControllerOriginalImage];
[self.imageView setImage:self.chosenImage];
[self dismissViewControllerAnimated:YES completion:nil];
EditViewController *editViewController = [[EditViewController alloc]init];
editViewController.chosenImage = self.chosenImage;
[self.navigationController pushViewController:editViewController animated:YES];
}
EditViewController.h(申報物業的ImageView)
#import <UIKit/UIKit.h>
@interface EditViewController : UIViewController
@property (strong,nonatomic) UIImage *chosenImage;
@end
將editviewcontroller的東西放入dismissViewControllerAnimated的完成處理程序中。 –