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
38
votes
1 answer

How to use a 'Container View' in iOS?

I have noticed the UI Component in XCode: Container View. Based on the description provided I would like to make use of it to display a reusable component of my app in several different screens. I have been looking around online to try and find a…
user843337
38
votes
9 answers

iOS: present view controller programmatically

I'm using the presentViewController:animated:completion: method to go to another view controller. This is my code: AddTaskViewController *add = [[AddTaskViewController alloc] init]; [self presentViewController:add animated:YES completion:nil]; This…
37
votes
7 answers

Swapping rootViewController with animation

I'm having a little trouble swapping rootViewControllers with animation. Here's the code that I'm using: [UIView transitionWithView:self.window duration:0.8 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{ …
edc1591
  • 10,146
  • 6
  • 40
  • 63
37
votes
5 answers

How to do the flip animation between two UIViewControllers while clicking info button?

I have a login page named "LoginViewController". I have an info button in this page. If I click on it, I want to show some information about my application. Also I want to present that information page using flip animation. The code for creating…
Rajkanth
37
votes
5 answers

Order of UIViewController initialization and loading

I'm fairly new to UI programming on the Mac and iPhone, and I've run across something that somewhat puzzles me. A UIViewController has 3 methods that involve the initialization of it and its view: init (and init-like methods) loadView viewDidLoad…
Dani
  • 698
  • 1
  • 7
  • 14
37
votes
4 answers

difference between presentViewController and UINavigationController?

Please tell the difference between presentViewController and UiNavigationController? Could I use presentViewController instead of UINavigationController to navigate different views in the app? Whats the scenario to use either?
user1940888
  • 475
  • 1
  • 6
  • 11
37
votes
5 answers

UIViewControllerHierarchyInconsistency when trying to present a modal view controller

Trying to present a modal view controller with the following code MapViewController *mapView = [[MapViewController alloc] initWithNibName:@"MapViewController" bundle:nil]; mapView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; …
Sam J.
  • 685
  • 1
  • 8
  • 22
36
votes
5 answers

iOS 11 large title navigation bar snaps instead of smooth transition

I'm facing an issue where the large title navigation bar collapses very abruptly when scrolling on a UITableView embedded inside of a UIViewController. The problem seems to only occur when scrolling up on the screen. When scrolling down on the…
Villarrealized
  • 867
  • 1
  • 6
  • 13
36
votes
1 answer

presentingViewController is nil when using presentViewController:animated:completion: in iOS 8

Wondering if anyone else has encountered this issue recently... For one of my view controllers , only on iOS 8, after calling presentViewController:animated:completion:, the presented view controller has self.presentingController as nil. It is fine…
Ken Ko
  • 1,517
  • 2
  • 15
  • 21
35
votes
5 answers

Easiest way to support multiple orientations? How do I load a custom NIB when the application is in Landscape?

I have an application in which I would like to support multiple orientations. I have two .xib files that I want to use, myViewController.xib and myViewControllerLandscape.xib. myViewController.xib exists in project/Resources and…
Peter Hajas
  • 4,011
  • 4
  • 25
  • 28
35
votes
4 answers

How to implement UIPageViewController that utilizes multiple ViewControllers

I've been working on a simple test app to learn the ins and outs of the UIPageViewController. I have it working but I'm not convinced my execution is the best way. I hope some of you can point me in the right direction. To get a basic…
Ben
  • 967
  • 3
  • 9
  • 23
34
votes
1 answer

"UIViewController subclass" does not appear in file template library for xcode 4.3

I am fairly new to XCODE development currently following several tutorials. Bumped into an unexpected problem - looking for help! The problem is that the "UIViewController subclass" does not appear in the file template library. My book and every…
Shin
  • 363
  • 1
  • 3
  • 7
34
votes
11 answers

UIViewController -viewDidLoad not being called

Being new to Cocoa, I'm having a few issues with Interface Builder, UIViewController and friends. I have a UIViewController subclass with a UIView defined in a xib, and with the controller's view outlet connected to the view. The xib's "file's…
Justicle
  • 14,761
  • 17
  • 70
  • 94
34
votes
1 answer

When to use addChildViewController vs pushViewController

I just watched a 2011 WWDC presentation on "Implementing UIViewController Containment" (here's a link to the video) They mentioned both of these ways of adding viewControllers to the screen, and I would appreciate some clarification on best…
RanLearns
  • 4,086
  • 5
  • 44
  • 81
34
votes
3 answers

In UINavigationController what is the difference between topViewController, visibleViewController, presentedViewController?

UINavigationController has 3 controllers that all sound very similar to me: topViewController, visibleViewController, and presentedViewController. Which scenarios do you use each of these controllers in?