- 选中某个图片后,显示出来。
- - (void)showPicker
- {
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
- picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- picker.delegate = self;
- [self presentModalViewController:picker animated:YES];
- [picker release];
- }
- // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- - (void)viewDidLoad {
- [super viewDidLoad];
- UIButton *button = [UIButton buttonWithType: UIButtonTypeRoundedRect];
- button.frame = CGRectMake(10.0f, 60.0f, 120.0f, 30.0f);
- [button setTitle: @"Picker" forState: UIControlStateNormal];
- [button addTarget: self action: @selector(showPicker) forControlEvents: UIControlEventTouchUpInside];
- [self.view addSubview: button];
- m_imageView = [[UIImageView alloc] initWithImage: nil];
- m_imageView.frame = CGRectMake(120.0f, 120.0f, 60.0f, 60.0f);
- [self.view addSubview: m_imageView];
- }
- #pragma mark delegate
- - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)aImage editingInfo:(NSDictionary *)editingInfo
- {
- m_imageView.image = aImage;
- [picker dismissModalViewControllerAnimated:YES];
- }
iOS 调用相册
最新推荐文章于 2021-11-24 20:53:49 发布