IOS imagePicker is easy to use! Three steps are easy !, Iosimagepicker
You can modify your profile picture to make it easier to query and use! Forwarding
Step: 1. comply with the proxy agreement
<UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIActionSheetDelegate>
2. Click Event {
UIActionSheet * choosePhotoActionSheet;
If ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
ChoosePhotoActionSheet = [[UIActionSheet alloc] initWithTitle: NSLocalizedString (@ "select image ",@"")
Delegate: self
CancelButtonTitle: NSLocalizedString (@ "cancel ",@"")
DestructiveButtonTitle: nil
OtherButtonTitles: NSLocalizedString (@ "camera", @ ""), NSLocalizedString (@ "album", @ ""), nil];
} Else {
ChoosePhotoActionSheet = [[UIActionSheet alloc] initWithTitle: NSLocalizedString (@ "select image ",@"")
Delegate: self
CancelButtonTitle: NSLocalizedString (@ "cancel ",@"")
DestructiveButtonTitle
: Nil
OtherButtonTitles: NSLocalizedString (@ "album", @ ""), nil];
}
[ChoosePhotoActionSheet showInView: self. view];
}
3. Implement proxy Methods
# Pragma mark-UIActionSheetDelegate
-(Void) actionSheet :( UIActionSheet *) actionSheet clickedButtonAtIndex :( NSInteger) buttonIndex
{
NSUInteger sourceType = 0;
If ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
Switch (buttonIndex ){
Case 0:
SourceType = UIImagePickerControllerSourceTypeCamera;
Break;
Case 1:
SourceType = UIImagePickerControllerSourceTypePhotoLibrary;
Break;
Case 2:
Return;
}
} Else {
If (buttonIndex = 1 ){
Return;
} Else {
SourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
}
}
UIImagePickerController * imagePickerController = [[UIImagePickerController alloc] init];
ImagePickerController. delegate = self;
ImagePickerController. allowsEditing = YES;
ImagePickerController. sourceType = sourceType;
[Self presentViewController: imagePickerController animated: YES completion: ^ {
}];
}
# Pragma mark-UIImagePickerControllerDelegate
-(Void) imagePickerController :( UIImagePickerController *) picker didFinishPickingMediaWithInfo :( NSDictionary *) info
{
[Self dismissViewControllerAnimated: YES completion: ^ {
}];
Self. tmpHeaderImg = [info objectForKey: UIImagePickerControllerEditedImage];
[Self. imageViewUserHead setImage: self. tmpHeaderImg];
[Self uploadImage];
}
-(Void) imagePickerControllerDidCancel :( UIImagePickerController *) picker
{
[Self dismissViewControllerAnimated: YES completion: ^ {
}];
}