Skip to content

Instantly share code, notes, and snippets.

@sunnycyk
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunnycyk/680966b5b72d336c33c1 to your computer and use it in GitHub Desktop.
Save sunnycyk/680966b5b72d336c33c1 to your computer and use it in GitHub Desktop.
ios 8 notes
#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;
}
}
// 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];
}
-(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;
}
// 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