Skip to content

Commit

Permalink
Changing profile causes crash on iPad
Browse files Browse the repository at this point in the history
[Deliver #28836769]
  • Loading branch information
nwg committed May 3, 2012
1 parent 49fe60e commit e694106
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Socialize/Classes/SocializeProfileEditViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ typedef enum {
@class SocializeProfileEditTableViewCell;
@class SocializeProfileEditValueViewController;

@interface SocializeProfileEditViewController : SocializeBaseViewController <UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITableViewDataSource, UITableViewDelegate>
@interface SocializeProfileEditViewController : SocializeBaseViewController <UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITableViewDataSource, UITableViewDelegate, UIPopoverControllerDelegate>
@property (nonatomic, retain) id<SocializeFullUser> fullUser;
@property (nonatomic, retain) UIImage *profileImage;
@property (nonatomic, retain) NSArray *cellBackgroundColors;
Expand All @@ -58,6 +58,7 @@ typedef enum {
@property (nonatomic, assign) BOOL editOccured;
@property (nonatomic, retain) UIBarButtonItem *saveButton;
@property (nonatomic, retain) NSMutableArray *facebookCells;
@property (nonatomic, retain) UIPopoverController *popover;

+ (UINavigationController*)profileEditViewControllerInNavigationController;
+ (SocializeProfileEditViewController*)profileEditViewController;
Expand Down
22 changes: 18 additions & 4 deletions Socialize/Classes/SocializeProfileEditViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ @implementation SocializeProfileEditViewController
@synthesize facebookCells = facebookCells_;
@synthesize showFacebookLogout = showFacebookLogout_;
@synthesize showTwitterLogout = showTwitterLogout_;
@synthesize popover = popover_;

+ (UINavigationController*)profileEditViewControllerInNavigationController {
SocializeProfileEditViewController *profileEditViewController = [self profileEditViewController];
Expand All @@ -97,7 +98,8 @@ - (void)dealloc {
self.userDefaults = nil;
self.saveButton = nil;
self.facebookCells = nil;

self.popover = nil;

[super dealloc];
}

Expand Down Expand Up @@ -543,8 +545,9 @@ - (UIImagePickerController*)imagePicker {

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
DebugLog(@"getting callback from actions sheet. index is %i and cancel button index is:%i", buttonIndex, actionSheet.cancelButtonIndex);
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];

if( buttonIndex == actionSheet.cancelButtonIndex ) {
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
return;
}
if (buttonIndex == 1) {
Expand All @@ -553,7 +556,14 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger
self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}

[self presentModalViewController:self.imagePicker animated:YES];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
self.popover = [[[UIPopoverController alloc] initWithContentViewController:self.imagePicker] autorelease];
self.popover.delegate = self;
CGRect rect = self.profileImageCell.frame;
[self.popover presentPopoverFromRect:rect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
} else {
[self presentModalViewController:self.imagePicker animated:YES];
}
}

- (void)configureForAfterEdit {
Expand All @@ -564,7 +574,11 @@ - (void)configureForAfterEdit {
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];

[picker dismissModalViewControllerAnimated:YES];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[self.popover dismissPopoverAnimated:YES];
} else {
[picker dismissModalViewControllerAnimated:YES];
}

[self configureForAfterEdit];
[self setProfileImageFromImage:image];
Expand Down

0 comments on commit e694106

Please sign in to comment.