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

How can I add a UIView as a subview of UIViewController when a button clicked?

In my app I need to add a UIView dynamically whenever user taps on a button in my main UIViewController. How can I do this?
iphoneStruggler
  • 123
  • 2
  • 3
  • 10
4
votes
3 answers

UIAlertController background color iOS10

Code that I wrote for iOS9, worked really well: UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Select source" message:nil …
Stefan
  • 1,283
  • 15
  • 33
4
votes
2 answers

viewDidLayoutSubviews no longer called when popping top view with UINavigationController

iOS 10, the gift that keeps on breaking, seems to have changed another behavior. Assume two UIViewControllers are pushed onto a UINavigationController. On iOS 8/9, calling navigationController?.popViewController(animated: true) to pop the top…
4
votes
2 answers

How to check that user is back from Settings

I am sending local notifications to my users, and I want to show the relevant title on the notification settings button. If local notifications are off, this title should be "Notifications: off", and if local notifications are on, this title should…
lithium
  • 1,272
  • 1
  • 14
  • 28
4
votes
1 answer

Using CNContactViewController without adding a contact (swift)

I want to use contactsUI CNContactViewController.init(forNewContact: a) for view only and take the value to the server. However, right now the func also adding a contact to addressbook/contact app, is it possible to prevent this?
Aldo Lazuardi
  • 1,898
  • 2
  • 19
  • 34
4
votes
6 answers

How to dismiss viewController in ios using Swift

I have a viewController which contains only an imageview. I want to present it whenever there is a loading in the application like fetching data from a webservice. So I have created a function in my loaderViewController as func…
Byte
  • 629
  • 2
  • 11
  • 29
4
votes
2 answers

How to properly dismiss modal viewcontroller with completion handler

I have viewController1 and viewController2 which is modaly presented and I want to use the completion handler when I dismiss the 2nd, but I can't get the implementation. I thought that I have to write a function and just put it there…
i6x86
  • 1,557
  • 6
  • 23
  • 42
4
votes
1 answer

Managing multiple UIViews from one UIViewController

I'm getting confused on view controllers and would love a straight example. Here's the preamble: I have a UIViewController with a matching .xib. By default IB gives me a single View in the Document window. I can make it appear by telling my UIWindow…
Cocoadelica
  • 3,006
  • 27
  • 30
4
votes
1 answer

Cannot call value of non-function type "UIViewController?"

I want to make an alert dialog showing up with messages and here's my code in ViewController.swift: func showErrorAlert(title: String , msg: String){ let alert = UIAlertController(title: title, message: msg, preferredStyle: .Alert) let…
Deidara
  • 667
  • 2
  • 13
  • 28
4
votes
1 answer

swift deinit method not working when UIView is removed from memory

In Swift ARC is calling deinit when any UIViewController is removing from memory , but it's not getting called if any UIView is removed from memory. for example In case of UIViewController Class deinit is working great class…
Anupam Mishra
  • 3,408
  • 5
  • 35
  • 63
4
votes
0 answers

XCode 7, show(push) segue showing up as modal with no back button

My layout in interface builder is as follows. Initial View Controller: Button 1 ------modal segue--------> UIViewController Initial View Controller: Button 2 ------show segue------->UINavigationController-------->UITableViewcontroller The segue from…
Joseph Toronto
  • 1,882
  • 1
  • 15
  • 29
4
votes
4 answers

Pushing View Controller Twice

Within my app I'm having an issue with the following error: Pushing the same view controller instance more than once is not supported It's a bug report that's comeback from a few users. We've tried to replicate it but can't (double tapping buttons…
Jahoe
  • 1,666
  • 2
  • 12
  • 27
4
votes
0 answers

prefersStatusBarHidden not working with presentation "Over Full Screen"

I have Viewcontroller "Home" that have Menu button on navigationBar, when user click on meny i display ViewController over home to display Menu. To do this i set "Defines context" to the home ViewController and Presentation to "Over Full Screen"…
OuSS
  • 1,047
  • 1
  • 15
  • 23
4
votes
1 answer

How to create SnapChat TableView effect

I have my application set up such that the user can swipe left or right to navigate between view controllers, similar to SnapChat. I implemented this using a UIScrollView with paging enabled. One feature from SnapChat I would also like to implement…
Lahav
  • 781
  • 10
  • 22
4
votes
2 answers

Issue with calling viewWillAppear of presenting view controller when presented one is dismissed

I currently have a base view controller say AVC which present another view controller say BVC over current context like this: let bvc: BVC = sb.instantiateViewControllerWithIdentifier("BVC") as! BVC bvc.modalPresentationStyle =…
Shivam Bhalla
  • 1,879
  • 5
  • 35
  • 63