Questions tagged [uiviewcontroller]

The UIViewController class manages the views in iOS apps and mediates the interaction between an app's views, its underlying model objects, and the overall workflow.

The UIViewController class manages the views in iOS and watch-os apps and mediates the interaction between an app's views, its underlying model objects, and the overall workflow.

View controllers are the foundation of your app’s internal structure. Every app has at least one view controller, and most apps have several. Each view controller manages a portion of your app’s user interface as well as the interactions between that interface and the underlying data. View controllers also facilitate transitions between different parts of your user interface.

To quote from the Overview of the UIViewController Class Reference:

The UIViewController class provides the fundamental view-management model for all iOS apps. You rarely instantiate UIViewController objects directly. Instead, you instantiate subclasses of the UIViewController class based on the specific task each subclass performs. A view controller manages a set of views that make up a portion of your app’s user interface. As part of the controller layer of your app, a view controller coordinates its efforts with model objects and other controller objects—including other view controllers—so your app presents a single coherent user interface.

References:

16290 questions
49
votes
13 answers

How to get UIScrollView vertical direction in Swift?

How can I get the scroll/swipe direction for up/down in a VC? I want to add a UIScrollView or something else in my VC that can see if the user swipes/scrolls up or down and then hide/show a UIView depending if it was an up/down gesture.
user2722667
  • 8,195
  • 14
  • 52
  • 100
49
votes
3 answers

How add tabs programmatically in UITabBarController with swift?

How to create programmatically tabs from any class extended by UIViewController: class DashboardTabBarController: UITabBarController { override func viewDidLoad() { //here } ... }
gellezzz
  • 1,165
  • 2
  • 12
  • 21
49
votes
5 answers

How to detect if view controller is being popped of from the navigation controller?

I currently need to implement some code when the top view controller is being popped off from my navigation controller. Is there a way to detect when the view controller is being popped off the navigation controller stack? As much as possible I…
aresz
  • 2,589
  • 6
  • 34
  • 51
47
votes
22 answers

iPhone - dismiss multiple ViewControllers

I have a long View Controllers hierarchy; in the first View Controller I use this code: SecondViewController *svc = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; [self presentModalViewController:svc…
Oscar Peli
  • 1,108
  • 2
  • 11
  • 18
46
votes
5 answers

Why the 20px gap at the top of my UIViewController?

The Problem Consider the following controller hierarchy: UINavigationController UIViewController UITableViewController The presence of the UIViewController is affecting layout. Without it, the UITableViewController takes up the entire bounds…
Kent Boogaart
  • 175,602
  • 35
  • 392
  • 393
46
votes
2 answers

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

I'm interested in a concise example of how to create an NSObject subclass that implements the UIViewControllerInteractiveTransitioning protocol to manage a custom interactive transition between two UIViewControllers. Ideally in response to a swipe…
Alfie Hanssen
  • 16,964
  • 12
  • 68
  • 74
46
votes
8 answers

Container View getting pushed down as if it had a UINavigationBar?

I have a UIViewController with a Container View. This Container View contains a UITableViewController. The UIViewController is embedded in a UINavigationController. I configure the NavigationBar by changing the tint color, the bar tint color and…
Eric
  • 3,301
  • 4
  • 33
  • 39
45
votes
10 answers

Reloading a ViewController

I have a View controller displaying some information (not table views). I have an update call to a remote server which fills my data base. I would like to completely reload my ViewController after the update call is done. What should I do?
Tiago Veloso
  • 8,513
  • 17
  • 64
  • 85
45
votes
4 answers

In iOS 9, why is SFSafariViewController is being pushed instead of presented modally?

I'm presenting a SFSafariViewController by calling presentViewController:animated:completion: on a UIViewController instance. The result is that it gets pushed on (slides in from the right), as if I called pushViewController:animated: on a…
abc123
  • 8,043
  • 7
  • 49
  • 80
45
votes
15 answers

How to Dismiss 2 Modal View Controllers in Succession?

I have 2 view controllers presented modally. A presents B which presents C. When I dismiss C I would like to dismiss B as well. But I am not sure how to do this: Dismiss C: [self dismissModalViewControllerAnimated:YES] //[delegate dismissB] //this…
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
45
votes
5 answers

Present View Controller in Storyboard with a Navigation Controller - Swift

I am currently showing a viewController in my new storyboard below: var storyboard : UIStoryboard = UIStoryboard(name: AccountStoryboard, bundle: nil) var vc : WelcomeViewController = storyboard.instantiateViewControllerWithIdentifier("WelcomeID")…
Fudgey
  • 3,793
  • 7
  • 32
  • 53
45
votes
5 answers

When is UIViewController viewDidUnload called?

Note: This question is outdated—viewDidUnload is deprecated iOS 6. When does UIViewController's viewDidUnload automatically get called? Yes I know, when the view unloads. But when does that happen automatically? How can I do it manually? Thanks.
mk12
  • 25,873
  • 32
  • 98
  • 137
44
votes
7 answers

Instantiate View Controller from Storyboard vs. Creating New Instance

What is the functional difference between instantiating a View Controller from the storyboard and creating a new instance of it? For example: #import "SomeViewController.h" ... SomeViewController *someViewController = [SomeViewController…
Benjamin Martin
  • 1,795
  • 3
  • 15
  • 17
44
votes
5 answers

IOS7 Status bar hide/show on select controllers

I would like to show and hide the Status bar on some controllers. Can this be done or is it more of an overall app setting. I have seen many posts/questions about the plist update: View controller-based status bar appearance - NO If this is…
StuartM
  • 6,743
  • 18
  • 84
  • 160
44
votes
1 answer

Add UIGestureRecognizer to swipe left to right right to left my views

I have a UIStoryboard with different UIViewControllers, I would like to add another UIViewController (like a dashboard) that when the user swipe the ipad from left the dashboard will appear then when he swipe back the current view will be…