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
6 answers

How to hint use of UIView subclass for compiler

I have a subclass of UIViewController that is responsible for a single UIWebView. Since this is a simple case, I override -(void)loadView, instantiate the UIWebView and assigning it the controller's view property: - (void)loadView { UIWebView…
Carlton Gibson
  • 7,278
  • 2
  • 36
  • 46
4
votes
1 answer

Removing a UIView

So I have a view controller called MainViewController with a button which when I press this code is called: NewViewController *newViewController; newViewController = [[NewViewController alloc] initWithNibName:@"NewView"…
ingh.am
  • 25,981
  • 43
  • 130
  • 177
4
votes
1 answer

Navigation controller issue in container view controller

Phase 1: I have a controller embedded inside a navigation controller. I am trying to create a custom container view inside this controller. Phase 2: I have created xib of UIView which contain scrollView which I am passing in controller initialiser…
4
votes
5 answers

Create an array of objects that implements a specific protocol

TL;DR I'm looking for an array type (var array = [TheTypeImLookingFor]()) like 'all objects that subclasses UIViewController and implements the protocol MyProtocol. Explanation I'm building a kind of wizard view with a container view and embedded…
Tobonaut
  • 2,245
  • 2
  • 26
  • 39
4
votes
1 answer

How to change view of my viewController programmatically?

I can change the class of the view in an UIViewController using the Storyboard like so: How can I achieve the same effect programmatically? I've tried this: convenience init() { print("convenience init") self.init(nibName: nil, bundle:…
Vladislav
  • 1,392
  • 1
  • 12
  • 21
4
votes
6 answers

Pass Data using a pushViewController?

Using this code I am able to 'segue' to the same instance of my view controller func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc…
baxu
  • 303
  • 1
  • 4
  • 12
4
votes
0 answers

UISplitViewController programatically, weird behavior during transition master -> detail in Swift 3

We implemented UISplitViewController without using storyboard. Our split view controller consists of master and detail controllers, both individually wrapped within UINavigationController. We configured split view controller with following: set…
4
votes
1 answer

UINavigationController: show embedded view controllers with different orientations after each transition?

This is a common question on StackOverflow, but none of the other solutions worked. Many were also written several years ago. Here are some of the posts considered: Is it possible to have different orientations for viewControllers inside…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
4
votes
2 answers

How can I add a view from subviews on top of its superview?

I have a mainViewController and inside its nib file I added an info button, in which action is to flip between two subviews, subview A and subview B. From mainViewController, under viewDidLoad, I'm inserting subview A. Here I notice that the info…
Ole Media
  • 1,652
  • 9
  • 25
  • 36
4
votes
4 answers

iOS10: How to avoid memory leaks in a segue circle

I have 4 scenes in my project, and page1 can segue(type is show) to page2, then can segue to page3, then to page4, then back to page1. You understand that in 1 second from my storyboard: The class of controller of these four scene is…
Sayakiss
  • 6,878
  • 8
  • 61
  • 107
4
votes
2 answers

presentModalViewController does nothing

I have a UIViewController (parent) that calls presentModalViewController with another UIViewController (child) on viewDidLoad. If parent doesn't have a UINavigationController, then presentModalViewController does nothing. If it has a…
hpique
  • 119,096
  • 131
  • 338
  • 476
4
votes
2 answers

unwind segue not triggering

I have been learning swift and have made the foundation of most of my app. I have the following storyboard app storyboard Everything works fine. For example, I have an unwind segue on the add course view controller that triggers when you press save…
Baz M
  • 75
  • 1
  • 10
4
votes
3 answers

viewDidLoad vs ViewWillAppear in IOS

Please help me with this. I have created a simple project with two views as shown. I have attached the images for my storyboard and swift files. So, I read that viewdidload will be executed only once while loading the view into the memory. But, when…
Swifty
  • 65
  • 1
  • 8
4
votes
2 answers

Animating UIScrollView rightwards

How to create an animation that moves/scrolls a seeable image section at an uniform speed rightwards? OR rather: How to animate UIScrollView rightwards? Example: The image width is 4968 px. The image is used as a fullscreen background image. Only…
Maximilian Fuchs
  • 441
  • 1
  • 6
  • 15
4
votes
1 answer

State Restoration not working when presenting viewcontroller?

I am not using storyboards. And currently in ViewController1. Here on a button click event I call this code. InnerViewController *innerVc = [[InnerViewController alloc] initWithNibName:@"InnerViewController" bundle:nil titleText:@"vaibhav"]; …
user3693546