Last active
August 29, 2015 14:23
-
-
Save sunnycyk/680966b5b72d336c33c1 to your computer and use it in GitHub Desktop.
ios 8 notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark -MFMEssageComposeViewControllerDelegate | |
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller | |
didFinishWithResult:(MessageComposeResult)result { | |
switch(result) { | |
case MessageComposeResultCancelled: | |
// user canceled sms | |
[self dismissViewControllerAnimated:YES completion:nil]; | |
break; | |
case MessageComposeResultSent: | |
// user sent sms | |
[self dismissViewControllerAnimated:YES completion:nil]; | |
break; | |
case MessageComposeResultFailed: | |
// sms send failed | |
//perhaps put an alert | |
[self dismissViewControllerAnimated:YES completion:nil]; | |
break; | |
default: | |
[self dismissViewControllerAnimated:YES completion:nil]; | |
break; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// check if the app has permission to sent message with iMessage | |
if ([MFMessageComposeViewController canSendText]) { | |
// create new MFMMessageComposeViewController instance | |
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init]; | |
// Set Message Body | |
controller.body = @"Anything you want to send!"; | |
// Array of recipients. In this case, none so that app user can enter recipient in iMessage Window | |
controller.recipients =@[]; | |
// -MFMEssageComposeViewControllerDelegate | |
controller.messageComposeDelegate = self; | |
// show the window | |
[self presentViewController:controller animated:YES completion:nil]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender | |
{ | |
if ([segue.identifier isEqualToString:@"popoverSegue"]) { | |
PopOverViewController *vc = [segue destinationViewController]; | |
vc.modalPresentationStyle = UIModalPresentationPopover; | |
vc.popoverPresentationController.delegate = self; | |
} | |
} | |
-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller | |
{ | |
return UIModalPresentationNone; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For example, PopUpViewController is subclass of UIViewController | |
PopUpViewController *vc = [[PopUpViewController alloc] init]; | |
// if there is a navigationController | |
self.navigationController.definesPresentationContent = YES; | |
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; | |
vc.modalPresentationStyle = UIModalPresentationOverCurrentContext; | |
[self presentViewController:vc animated:YES completion:nil]; | |
// Then in PopUpViewController, you may set transparent background color, and a UIView with padding constraint to the view. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment