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
4
votes
7 answers

How to present programmatically a view controller from a UIVIew

I am using a Class which is a subclass of MessageView (Swift Message Library) which is inherit from UIView. Inside, I have a UIButton and I want to present programmatically another ViewController through it. Here is my code below : import…
Blisko
  • 107
  • 2
  • 9
4
votes
3 answers

How can I close UIVIewController?

I have a MainWindowController that I want to close on "touch inside" button event and open a new UIView. The code that I use is this: NewViewController *controller = [[NewViewController alloc] initWithNibName:@"NewView"…
JAEP
  • 363
  • 2
  • 5
  • 12
4
votes
3 answers

Value of type 'UIView' has no member 'present' - how to invoke 'present'?

i have a uiview file that i embedded into my tableview header (class TopHeader: UIView, UICollectionViewDelegate, UICollectionViewDataSource) If I use present(_:animated:completion:) i am getting: Value of type TopHeader has no member 'present' ( …
Tel4tel
  • 51
  • 1
  • 2
  • 9
4
votes
2 answers

Back to specific view controller in swift 4

Let's say I have five view controllers and I want to go to the specific view controller RootViewController ==> FirstViewController ==> SecondViewController ==> ThirdViewController ==> FourthViewController(Modally presented having a button) and all…
Wings
  • 2,398
  • 23
  • 46
4
votes
2 answers

Swift iOS -Should Deinit get called inside child View Controller when added as a child to another View Controller?

I have a childVC(vc3) inside a parentVC(vc2) inside another parentVC(vc1). I'm doing it this way for animation purposes. What happens is I add vc3 as a child to vc2. I have a collectionView that pushes on vc1. Once vc1 is on scene vc2 is added to…
Lance Samaria
  • 17,576
  • 18
  • 108
  • 256
4
votes
1 answer

iPhone Alternate View for Landscape Mode on Rotation

I'm looking to have an alternate view for one of my ViewControllers when the user rotates the device to landscape (think CoverFlow in iPod) I have implemented this using the AlternateViews sample code (listening for a device rotation…
Jason McCreary
  • 71,546
  • 23
  • 135
  • 174
4
votes
1 answer

How to pass a Type of UIViewController to a function and type cast a variable in iOS Swift?

Explanation I am defining a generic API method to handle popup across my application. Is it possible to pass a type of a UIViewController to a function and type cast the variable popOverVC in the function to the type of popUpVC ie., passed to the…
Thomas Easo
  • 3,457
  • 3
  • 21
  • 32
4
votes
0 answers

Changing the key window does not call view will/did dis/appear

When I change the key window, the rootViewController(s) do not receive view will/did appear/disappear. SplashViewController *screenLockViewController = [[SplashViewController alloc] initWithNibName:@"SplashViewController" bundle:nil]; …
4
votes
2 answers

How to resize view when using UINavigationController setToolbarHidden:animated:

I'm using the UINavigationController toolbar. Before I display it, I resize my views so that they don't get blocked by the toolbar (I set the frame of the current view controller's view to the rect spanning from the bottom of the navigationBar to…
Cameron Spickert
  • 5,190
  • 1
  • 27
  • 34
4
votes
3 answers

ios uisegmentedcontrol with different sizes

I wish use a uisegmentedcontrol in my app with 3 segments but not with the same size, the first and the third smaller than the second... is this possible? how can I do this? thanks
ghiboz
  • 7,863
  • 21
  • 85
  • 131
4
votes
3 answers

How to get a fade out animation while dismissing a view controller

I have an Image view in my View Controller. I want to dismiss the view controller when a Pan gesture is recognized towards the down side of the view controller. While I have achieved dismiss the view controller with a Pan gesture, I am trying to…
SriTeja Chilakamarri
  • 2,463
  • 4
  • 16
  • 29
4
votes
0 answers

Why iOS 11 changed next view controller's viewDidLoad before viewWillDisappear

I have two view controllers in one navigation controller. When the first one push the second one, second view controller's viewDidLoad called before first one's viewWillDisappear in iOS 11. But in iOS 10 and before, I have the opposite result. I…
Lumialxk
  • 6,239
  • 6
  • 24
  • 47
4
votes
2 answers

How do you handle view initialization order in a UIViewController when constructing the view manually?

I have a UIViewController that materializes its view in loadView (i.e. no nib). Per the documentation (and via confirmation in code), loadView and consequently, viewDidLoad will not get called until UIViewController's view is accessed the first…
rcw3
  • 3,034
  • 1
  • 27
  • 24
4
votes
1 answer

UINavigationController with two delegates?

Suppose I have a UINavigationController upon which I want to perform custom transitions. For convenience, I define a transition class: class WTPTransition: NSObject { // This is our Interaction Controller, which conforms to…
GoldenJoe
  • 7,874
  • 7
  • 53
  • 92
4
votes
2 answers

How to reload a view controller when back from another view using tab bar

I have a common view used when the user opens the app (VC1). With a tab bar controller, I load another view (VC2) that can be used to update data visible in the previous one. When I go back on VC1 (which is stack), it does not reload with updated…
Bastien
  • 117
  • 1
  • 1
  • 7