mwaterfall/MWPhotoBrowser — Issue #26: crush on idevice with no mail account
Author: Undermaken
Created: 2012-01-18 16:14:12+00:00
State: open

I found a bug: when display an image and the current device hasn't a valid email account configured, it displays 2 menu items correctly: "save,copy"
If you don't want one of these and tap to another point into the screen, that causes a crash (the buttonIndex is 2).

So you can fix it whit this code:

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (actionSheet == _actionsSheet) {
NSLog(@"%d - %d",buttonIndex,actionSheet.firstOtherButtonIndex);
self.actionsSheet = nil;
if (buttonIndex == actionSheet.firstOtherButtonIndex) {
[self savePhoto]; return;
} else if (buttonIndex == actionSheet.firstOtherButtonIndex + 1) {
[self copyPhoto]; return;
} else if (buttonIndex == actionSheet.firstOtherButtonIndex + 2 && [MFMailComposeViewController canSendMail]) {
[self emailPhoto]; return;
}
}
[self hideControlsAfterDelay]; // Continue as normal...
}