Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5dbdd1d

Browse files
author
Ignacio Romero Zurbuchen
committed
Fixes crash in sample project iOS 7 only
1 parent 7ec47ff commit 5dbdd1d

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

Examples/Messenger-Shared/MessageViewController.m

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,23 @@ - (void)simulateUserTyping:(id)sender
194194
- (void)didLongPressCell:(UIGestureRecognizer *)gesture
195195
{
196196
#ifdef __IPHONE_8_0
197-
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
198-
alertController.modalPresentationStyle = UIModalPresentationPopover;
199-
alertController.popoverPresentationController.sourceView = gesture.view.superview;
200-
alertController.popoverPresentationController.sourceRect = gesture.view.frame;
201-
202-
[alertController addAction:[UIAlertAction actionWithTitle:@"Edit Message" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
197+
if ([UIAlertController class]) {
198+
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
199+
alertController.modalPresentationStyle = UIModalPresentationPopover;
200+
alertController.popoverPresentationController.sourceView = gesture.view.superview;
201+
alertController.popoverPresentationController.sourceRect = gesture.view.frame;
202+
203+
[alertController addAction:[UIAlertAction actionWithTitle:@"Edit Message" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
204+
[self editCellMessage:gesture];
205+
}]];
206+
207+
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:NULL]];
208+
209+
[self.navigationController presentViewController:alertController animated:YES completion:nil];
210+
}
211+
else {
203212
[self editCellMessage:gesture];
204-
}]];
205-
206-
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:NULL]];
207-
208-
[self.navigationController presentViewController:alertController animated:YES completion:nil];
213+
}
209214
#else
210215
[self editCellMessage:gesture];
211216
#endif

0 commit comments

Comments
 (0)