Permalink
Browse files

Changing profile causes crash on iPad

[Deliver #28836769]
  • Loading branch information...
1 parent 49fe60e commit e6941064196a7cb0632affc2956dc2d6b6b07dd9 @nwg nwg committed May 3, 2012
@@ -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;
@@ -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;
@@ -71,6 +71,7 @@ @implementation SocializeProfileEditViewController
@synthesize facebookCells = facebookCells_;
@synthesize showFacebookLogout = showFacebookLogout_;
@synthesize showTwitterLogout = showTwitterLogout_;
+@synthesize popover = popover_;
+ (UINavigationController*)profileEditViewControllerInNavigationController {
SocializeProfileEditViewController *profileEditViewController = [self profileEditViewController];
@@ -97,7 +98,8 @@ - (void)dealloc {
self.userDefaults = nil;
self.saveButton = nil;
self.facebookCells = nil;
-
+ self.popover = nil;
+
[super dealloc];
}
@@ -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) {
@@ -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 {
@@ -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];

0 comments on commit e694106

Please sign in to comment.