objective c - iOS how to start the image picker -
i have uibutton
, when user clicks it, want start image picker controller
i configure think enough couldn't know message have pass image picker start working
this code
#import "imagepickerviewcontroller.h" @interface imagepickerviewcontroller () @property (weak, nonatomic) iboutlet uiimageview *image; @end @implementation imagepickerviewcontroller - (void)viewdidload { [super viewdidload]; // additional setup after loading view. } - (ibaction)selectimage:(id)sender { uiimagepickercontroller *imagepicker = [[uiimagepickercontroller alloc]init]; imagepicker.delegate = self; imagepicker.sourcetype = uiimagepickercontrollersourcetypephotolibrary; } @end
i have set correct protocols:
@interface imagepickerviewcontroller : uiviewcontroller < uinavigationcontrollerdelegate,uiimagepickercontrollerdelegate> @end
you need present uiimagepicker
- (ibaction)selectimage:(id)sender { uiimagepickercontroller *imagepicker = [[uiimagepickercontroller alloc]init]; imagepicker.delegate = self; imagepicker.sourcetype = uiimagepickercontrollersourcetypephotolibrary; [self presentviewcontroller:imagepicker animated:no completion:nil]; }
Comments
Post a Comment