How to click the button
-(void) Catchimage {Uialertcontroller *alert = [Uialertcontroller alertcontrollerwithtitle:@ "Select message:@ to select Photos" pref Erredstyle:uialertcontrollerstylealert]; Uialertaction *action1 = [uialertaction actionwithtitle:@ "Camera" Style:uialertactionstyledefault handler:^ ( Uialertaction * _nonnull action) {if ([Uiimagepickercontroller issourcetypeavailable:uiimagepickercontroll Ersourcetypecamera]) {Uiimagepickercontroller *picker = [[Uiimagepickercontroller alloc] init]; Picker.sourcetype = Uiimagepickercontrollersourcetypecamera; Picker.delegate = self; picker.allowsediting = YES; [Self presentviewcontroller:self animated:yes completion:nil]; } else {Uialertcontroller *controller = [Uialertcontroller alertcontrollerwithtitle:@ "No webcam" Messa Ge:nil Preferredstyle:uialertcontrollerstyleactionsheet]; Uialertaction *action = [Uialertaction actionwithtitle: @ "OK" style:uialertactionstyledestructive Handler:nil]; [Controller addaction:action]; [Self Presentviewcontroller:controller animated:yes completion:nil]; } }]; [Alert Addaction:action1]; Uialertaction *action2 = [uialertaction actionwithtitle:@ "album" Style:uialertactionstyledefault handler:^ ( Uialertaction * _nonnull action) {Uiimagepickercontroller *picker = [[Uiimagepickercontroller alloc] init] ; Picker.sourcetype = uiimagepickercontrollersourcetypephotolibrary; Picker.delegate = self; picker.allowsediting = YES; [Self Presentviewcontroller:picker animated:yes completion:nil]; }]; [Alert Addaction:action2]; [Self Presentviewcontroller:alert animated:yes completion:nil];} method to execute after selecting the picture-(void) Imagepickercontroller: (Uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: ( Nsdictionary<nsstring *,id> *) Info {UIImage *image = [info objectforkey:uiimagepickercontrolleroriginalimage]; Self.imageView.image = image; [Picker Dismissviewcontrolleranimated:yes completion:nil];} -(void) viewdidload {[Super viewdidload]; _button = [UIButton buttonwithtype:uibuttontyperoundedrect]; [_button settitle:@ "select Avatar" Forstate:uicontrolstatenormal]; _button.frame = CGRectMake (100, 100, 100, 30); [_button addtarget:self Action: @selector (Catchimage) forcontrolevents:uicontroleventtouchupinside]; [Self.view Addsubview:_button]; _imageview = [[Uiimageview alloc] Initwithframe:cgrectmake (100, 250, 150, 150)]; _imageview.backgroundcolor = [Uicolor Yellowcolor]; [Self.view Addsubview:_imageview]; Do any additional setup after loading the view.}
iOS development calls phone cameras and albums