When dealing with profiles-avatars, there are usually two options, one is to call the system camera, and the other is to call the System album. The Uiimagepickercontroller method is used here.
Add a gesture to the imageview of the Avatar position, or add a transparent button to implement the click Method, directly on the code:
-(Ibaction) Click: (ID) sender{//Create a reminder viewUialertcontroller*alertcontroller = [Uialertcontroller alertcontrollerwithtitle:@"Reminders"Message:nil Preferredstyle:uialertcontrollerstyleactionsheet]; Uialertaction*alertaction = [Uialertaction actionwithtitle:@"Camera"Style:uialertactionstyledestructive handler:^ (Uialertaction *action) { //determine if the device has a camera, there is a call system camera, no, remind the user if([Uiimagepickercontroller Issourcetypeavailable:uiimagepickercontrollersourcetypecamera]) {//Create a cameraUiimagepickercontroller*picker =[[Uiimagepickercontroller alloc] init]; //File OriginPicker.sourcetype= Uiimagepickercontrollersourcetypecamera;//specifies that the data source comes from the cameraPicker.Delegate= self;//Specify proxypicker.allowsediting= YES;//Allow Editing//Modal Eject[self presentviewcontroller:picker animated:yes completion:nil]; }Else{ //No webcam, remind users that your device does not have a webcamUialertcontroller*alertcontroller = [Uialertcontroller alertcontrollerwithtitle:@"your device does not have a webcam"Message:nil Preferredstyle:uialertcontrollerstylealert]; Uialertaction*alertaction1 = [Uialertaction actionwithtitle:@"Determine"style:uialertactionstyledestructive Handler:nil]; [Alertcontroller Addaction:alertaction1]; [Self Presentviewcontroller:alertcontroller animated:yes completion:nil]; } }]; [Alertcontroller addaction:alertaction]; Uialertaction*alertaction2 = [Uialertaction actionwithtitle:@"albums"Style:uialertactionstyledefault handler:^ (Uialertaction *action) {Uiimagepickercontroller*PICKERC =[[Uiimagepickercontroller alloc] init]; Pickerc.sourcetype= Uiimagepickercontrollersourcetypephotolibrary;//Specify the data source as an albumPickerc.Delegate= self;//Specify proxypickerc.allowsediting= YES;//Allow Editing[self Presentviewcontroller:pickerc animated:yes completion:nil]; }]; [Alertcontroller Addaction:alertaction2]; [Self Presentviewcontroller:alertcontroller animated:yes completion:nil];} //how to perform after selecting a picture- (void) Imagepickercontroller: (Uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: (NSDictionary *) info{NSLog (@"%@", info); UIImage*image =[Info objectforkey:uiimagepickercontrolleroriginalimage]; Self.photoImage.image=image; [Picker Dismissviewcontrolleranimated:yes completion:nil];}
Uiimagepickercontroller and Uialertcontroller used together