我是iPhone開發新手。我有兩個名爲pickerviewcontroller和secondviewcontroller的視圖,它們具有不同的xib文件。我通過UIImagePickerController界面從照片庫中選擇一張照片,並試圖在第二個視圖中顯示所選圖像。 pickerController是我的第一個視圖控制器。無法在secondviewcontroller中顯示圖像
pickerController.h文件
#import <UIKit/UIKit.h>
#import "SecondViewController.h"
@interface pickerControllerViewController : UIViewController<UIActionSheetDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate> {
IBOutlet UIButton *selectpic;
UIImageView *imageView;
}
@property (nonatomic,retain) UIImageView *imageView;
@property (nonatomic,retain) UIButton *selectpic;
-(IBAction)getpic:(id)sender;
//-(void)goNext: (UIImagePickerController *)picker;
@end
pickerController.m呸
#import "pickerControllerViewController.h"
@implementation pickerControllerViewController
@synthesize imageView,selectpic;
-(IBAction)getpic:(id)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController:picker animated:YES];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
SecondViewController *secview = [[SecondViewController alloc]initWithNibName:nil bundle:nil];
[secview setImage:imageView];
}
SecondVIewController.h文件
@interface SecondViewController :UIViewController{
IBOutlet UIImageView *imageView2;
}
-(void)setImage:(UIImage *)image;
@end
SecondVIewController.m文件
@implementation SecondViewController
-(void)setImage:(UIImage *)image{
imageView2 = image;
}
它沒有顯示任何錯誤。我無法在第二個視圖中顯示圖像。
您的類型都是搞砸了... UIImage和UIImage視圖之間有區別。我想知道爲什麼這不會崩潰所有的時間... – Eiko 2010-09-10 09:51:29
雅我同意。後來我改變了uiimageview到uiimage,並試圖itstill沒有得到。 – 2010-09-13 10:31:48