I am trying to set the UIImageView's image as the return of UIImagePickerController below. My UIImageView profileImageView is instantiated in viewdidload. Strangely, the UIImagePickerController returned image has not been displayed in profileImageView. Initially I thought it was the image issue, so I fixed it to SR-rewards.jpg. Adding NSLog, it shows [profileImageView setImage:[UIImage imageNamed:@"SR-rewards.jpg"]] has been executed, but profileImageView.image.size.height is 0.
Then I give it another shoot using
[profileImageView performSelectorOnMainThread:@selector(setImage:) withObject: [UIImage imageNamed:@"SR-rewards.jpg"] waitUntilDone:YES];
to run it in the main thread. Though, the image is still not displayed, profileImageView.image.size.height changes to 277.
Any idea for the cause? And how can I set the image?
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
[profileImageView setImage:[UIImage imageNamed:@"SR-rewards.jpg"]];//[self cropImage:smallImage];
NSLog(@"%f" , profileImageView.image.size.height);
[picker dismissViewControllerAnimated:YES completion:NULL];
}
Regards Hammer