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
30
votes
3 answers

Present view controller from app delegate

I'm attempting to present a view controller from the app delegate with this code: - (void)interstitialViewControllerRequestSucceeded:(UIViewController *)interstitialViewController { [self.window.rootViewController…
mikeholp
  • 965
  • 3
  • 11
  • 14
30
votes
6 answers

viewDidLoad for UIView?

What is the viewDidLoad for UIView? I have a UIView with xib. I would like to hide one of it's subviews when it is loaded. I tried to use this. - (id)initWithCoder:(NSCoder *)aDecoder{ .... _theView.hidden = YES; } But the subview _theView…
Luda
  • 7,282
  • 12
  • 79
  • 139
30
votes
13 answers

How to identify that an UIViewController is presented

I have created an UIViewController sub class which can either be pushed in a navigation stack of a UINavigationController or presented(modally) from any UIViewController. I need to identify whether my view controller is presented, if it is presented…
saikamesh
  • 4,569
  • 11
  • 53
  • 93
30
votes
3 answers

UIView vs UIViewController

Ok so i am realllly new to the iphone development and i've gotten pretty far for my knowledge. I just need help deciding how to program these 4-6 pictures into my project. I basically want to make a comic book with the user being able to swipe from…
Dane
  • 365
  • 1
  • 5
  • 11
29
votes
7 answers

iOS: different addSubview behavior between iOS 4.3 and 5.0

while coding in iOS 4.3 before, I found while add a view controller's view to another view with [superview addSubView:controller.view], the controller instance will not receive the -viewWillAppear/viewDidAppear message, than I found same issue in…
KrzyCube
  • 303
  • 3
  • 6
29
votes
5 answers

How do I override the "view" property in UIViewController?

I have a custom UIViewController and custom UIView. I'd like to override the viewcontroller.view property to return MyCustomUIView. Right now I have: @interface MyViewController : UIViewController { IBOutlet MyView* view; } @property…
Keith Fitzgerald
  • 5,651
  • 14
  • 43
  • 58
29
votes
3 answers

Handling app delegates and switching between views

I'm getting a warning about a semantic issue pertaining to passing a *const _strong to type id and cannot seem to fix it no matter what I change. I have two views at the moment, and have written this code. In iPadSpeckViewController.m, here is the…
Chris
  • 11,819
  • 19
  • 91
  • 145
29
votes
7 answers

Touch events on UITableView?

I have UIViewControllerand UITableView as child in the view, what I want to do is when I touch any row I am displaying a view at bottom. I want to hide that view if the user touch any where else then rows or the bottomView. The problem is when I…
Kapil Choubisa
  • 5,152
  • 9
  • 65
  • 100
29
votes
3 answers

How to push and present to UIViewController programmatically without segue in iOS Swift 3

I am using this code for push SHOW and MODALLY programmatically in iOS Objective C. And now want to know about Swift 3. NewsDetailsViewController *vc = instantiateViewControllerWithIdentifier:@"NewsDetailsVCID"]; vc.newsObj =…
reza_khalafi
  • 6,230
  • 7
  • 56
  • 82
29
votes
6 answers

iOS Swift: UIPageViewController - Turning page programmatically

I have a UIPageViewController, which works fine when we swipe left or right to turn pages. class ViewController: UIViewController, UIPageViewControllerDataSource { ... } Now I intend to provide Previous/Next button on the page too, so that pages…
Jasper
  • 8,440
  • 31
  • 92
  • 133
29
votes
1 answer

iOS 8 Navigation Bar Not Accessible in Second ViewController on Storyboard

I am new to iOS development and have not tried this programmatically yet. I would prefer to get this working in a storyboard. I'm following this somewhat outdated tutorial from XCode 4.5 in XCode 6.1 to create a series of views connected by one…
29
votes
1 answer

When are the ViewWillLayoutSubviews and ViewDidLayoutSubviews methods called?

When do the ViewWillLayoutSubviews and ViewDidLayoutSubviews methods of UIViewController get called? What is the status of the view's frame before willLayoutSubviews?
Waseem05
  • 1,184
  • 1
  • 13
  • 15
28
votes
3 answers

Linking a new viewcontroller to Storyboard?

There is probably a simple solution but I can't figure it out. I am using storyboards for the interface. I start with a tab bar controller, but before the user is allowed to use the app the user has to authenticate himself trough a loginview which…
Justin
  • 2,960
  • 2
  • 34
  • 48
28
votes
2 answers

UIViewController – issue with custom dismiss transition

Summary I have a content UIViewController that presents a settings UIViewController using a custom transition. The presentation is with presentViewController:animated:completion:. When I later dismiss the settings with…
Benjohn
  • 13,228
  • 9
  • 65
  • 127
28
votes
3 answers

Where to determine UIView size

Summary: How should the UIViewController know the size of its UIView instance when initialising that view? The dedicated initialisation method for an UIView is the initWithFrame:(CGRect)frame method. This sets the frame for the newly created UIView.…
drvdijk
  • 5,556
  • 2
  • 29
  • 48