Instantiate View Controller from Storyboard vs. Creating New Instance

The main difference is in how the subviews of your UIViewController get instantiated. In the second case, all the views you create in your storyboard will be automatically instantiated for you, and all the outlets and actions will be set up as you specified in the storyboard. In the first, case, none of that happens; … Read more

Add UIGestureRecognizer to swipe left to right right to left my views [duplicate]

UISwipeGestureRecognizer * swipeleft=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeleft:)]; swipeleft.direction=UISwipeGestureRecognizerDirectionLeft; [self.view addGestureRecognizer:swipeleft]; // SwipeRight UISwipeGestureRecognizer * swiperight=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swiperight:)]; swiperight.direction=UISwipeGestureRecognizerDirectionRight; [self.view addGestureRecognizer:swiperight]; // Implement Gesture Methods -(void)swipeleft:(UISwipeGestureRecognizer*)gestureRecognizer { //Do what you want here } -(void)swiperight:(UISwipeGestureRecognizer*)gestureRecognizer { //Do what you want here } Try this one. Here is the swift version of above code. Left Swipe var swipeleft = UISwipeGestureRecognizer(target: … Read more

IOS7 Status bar hide/show on select controllers

The plist setting “View controller-based status bar appearance” only controls if a per-controller based setting should be applied on iOS 7. If you set this plist option to NO, you have to manually enable and disable the status bar like (as it was until iOS 6): [[UIApplication sharedApplication] setStatusBarHidden:YES] If you set this plist option … Read more

How can I switch views programmatically in a view controller? (Xcode, iPhone)

If you’re in a Navigation Controller: ViewController *viewController = [[ViewController alloc] init]; [self.navigationController pushViewController:viewController animated:YES]; or if you just want to present a new view: ViewController *viewController = [[ViewController alloc] init]; [self presentViewController:viewController animated:YES completion:nil];

Reloading a ViewController

If you know your database has been updated and you want to just refresh your ViewController (which was my case). I didn’t find another solution but what I did was when my database updated, I called: [self viewDidLoad]; again, and it worked. Remember if you override other viewWillAppear or loadView then call them too in … Read more

Present View Controller in Storyboard with a Navigation Controller – Swift

You’re definitely on the right track. Unfortunately when you reference a view controller by its storyboard ID it will ignore the fact it is embedded within anything. Same goes for segues when you segue to something embedded, the destination view controller will be the embedding controller, not the controller you’re usually interested in. Anyhow, you … Read more

Proper way to implement a custom UIViewController interactive transition using UIViewControllerInteractiveTransitioning Delegate Protocol

1) The easiest way to tie a gesture to the UIViewControllerInteractiveTransitioning object, is making it subclass of UIPercentDrivenInteractiveTransition. Then where you implement the gesture handler, you call updateInteractiveTransition: here an example with code: -(void)handlePinch:(UIPinchGestureRecognizer *)pinch { CGFloat scale = pinch.scale; switch (pinch.state) { case UIGestureRecognizerStateBegan: { _startScale = scale; self.interactive = YES; [self.navigationController popViewControllerAnimated:YES]; break; … Read more