//in view did load//
{
UISwipeGestureRecognizer *rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
rightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[rightRecognizer setNumberOfTouchesRequired:1];
[self.view addGestureRecognizer:rightRecognizer];
UISwipeGestureRecognizer *leftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipeHandle:)];
leftRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[leftRecognizer setNumberOfTouchesRequired:1];
[self.view addGestureRecognizer:leftRecognizer];
}
- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{
[self.navigationController popViewControllerAnimated:YES];
}
- (void)leftSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{
[self performSegueWithIdentifier:@"forward" sender:self];
}
NSString *text = @"hello world";
NSURL *url = [NSURL URLWithString:@"http://airbob.github.io/lifeNumber"];
//UIImage *image = [UIImage imageNamed:@"roadfire-icon-square-200"];
UIActivityViewController *controller =
[[UIActivityViewController alloc]
initWithActivityItems:@[text, url]
applicationActivities:nil];
controller.excludedActivityTypes = @[UIActivityTypePrint,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypeAirDrop];
[self presentViewController:controller animated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:nil];
[self presentViewController:modalViewController animated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:nil];
CBModalViewController* modalViewController = [[CBModalViewController alloc] init];
/*this is inconrect if you use storyboard, use following method
(please note the controller identifier is the storyboard id in storyboard
*/
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main"
bundle: nil];
CBModalViewController * modalViewController = (CBModalViewController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"CBModalViewController"];
uncheck is initial view in storyboard 2.
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
CBFBViewController * startViewController = (CBFBViewController*)[storyboard instantiateViewControllerWithIdentifier: @"CBFBViewController"];
self.window.rootViewController = startViewController;
[self.window makeKeyAndVisible];
normally add the present controller in viewdidappear instead of viewdidload
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// Disable iOS 7 back gesture
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
self.navigationController.interactivePopGestureRecognizer.delegate = self;
}
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
return YES;
}