码迷,mamicode.com
首页 > 其他好文 > 详细

使用ImageView

时间:2016-06-12 18:37:31      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:

@property (strong, nonatomic) UIPopoverController *pop;
//选取图片
- (IBAction)selectImage:(UIButton *)sender { UIImagePickerController *picker = [[UIImagePickerController alloc] init]; if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; picker.delegate = self; self.pop = [[UIPopoverController alloc] initWithContentViewController:picker]; self.pop.delegate = self; [self.pop presentPopoverFromRect:sender.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; } }

实现UIImagePickerController委托方法:

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self.pop dismissPopoverAnimated:YES];
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info valueForKey:@"UIImagePickerControllerOriginalImage"];
    self.masterViewController.mainImage = image;
    self.imageView.image = image;
    [self.pop dismissPopoverAnimated:YES];
}

实现clearImage:方法,实现视图重设。

- (IBAction)clearImage:(id)sender
{
    self.imageView.image = nil;
    self.masterViewController.mainImage = nil;
}

 

使用ImageView

标签:

原文地址:http://www.cnblogs.com/fengmin/p/5578227.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!