Questions tagged [viewcontroller]

viewcontroller is a design pattern which is a hybrid of the view and controller components of the MVC architecture

A viewcontroller responds to events by dispatching calls to a mapping table which matches views and controllers with each event target. It is implemented as an object in many frameworks, including:

2792 questions
16
votes
4 answers

Swift 3, Xcode 8 Instantiate View Controller is not working

Xcode 8 when it compiles says to change instantiate viewcontroller with identifier to simply, instantiate view controller. I did that, why does it give two errors? I'm working with Swift 3. I want to change pages programmatically.I've read a lot…
Aleric
  • 301
  • 1
  • 3
  • 12
15
votes
2 answers

Dismiss pushed view controller

So I have a view controller which I display as follows: func showProfileForTrainer(trainer: Trainers) { let viewPTProfileVC = ViewPTProfileVC() viewPTProfileVC.trainer = trainer …
Doto Pototo
  • 686
  • 2
  • 9
  • 19
15
votes
3 answers

Set rounded corners on UIimage in UICollectionViewCell in swift

I have a simple problem that I cannot find a solution to on google, the docs or here. I have a Collectionview in my view controller. I have created a custom cell, DescriptionCell, that contains a UIImage. I want this image to have rounded corners.…
Jell92
  • 183
  • 1
  • 2
  • 6
15
votes
2 answers

How to dismiss the current ViewController and go to another View in Swift

I am new to Swift and I want to know how to dismiss the current view controller and go to another view. My storyboard is like the following: MainMenuView -> GameViewController -> GameOverView. I want to dismiss the GameViewController to go to the…
Michel Kansou
  • 2,851
  • 4
  • 13
  • 22
15
votes
2 answers

Presenting a view controller programmatically in swift

Hi I am trying to convert the following objective C code into swift to navigate from one view controller to another view controller when a button is clicked. any help would be much appreciated This is taken from apple's programming guide -…
Magesh
  • 277
  • 1
  • 4
  • 13
15
votes
6 answers

Why do my files keep disappearing from xcode's project navigator?

The project I'm working on started as a single view application with storyboard, and I've added 2 more view controllers, each with a .m and a .h file. However, every time I save, quit, and then restart, the 4 new files disappear from the project…
14
votes
3 answers

Difference between AppDelegate.m and View Controller.m

Could anyone tell me when we use the AppDelegate.m and AppDelegate.h during iPhone programming? I have used only the ViewController.m and ViewController.h for basic learning. I just want to know when and why AppDelegate is used.
Legolas
  • 12,145
  • 12
  • 79
  • 132
14
votes
2 answers

dismiss share extension custom viewcontroller

I am trying to create a custom view controller to be used with a share extension. Everything works, but I don't know how to dismiss the custom view controller. Basically I launch my share extension from safari and want to completely dismiss this…
Robert Marlan
  • 369
  • 2
  • 11
14
votes
5 answers

Presenting view controllers on detached view controllers

I have sideViewController with a button and Action, which present new view controller by clicking this button. class sideViewController: UIViewController { @IBOutlet var buttonVC1 : UIButton! @IBAction func goToVC1 () { var VC1 =…
Yury Alexandrov
  • 2,368
  • 5
  • 17
  • 17
13
votes
4 answers

Swift - Present another view controller with its navigation bar

I have two ViewControllers -- one with storyboard and one without. Both of those view controllers have their own Navigation Bar at the top. Now when I use self.presentViewController(editorViewController, animated: true, completion: nil) my…
Vasil Nunev
  • 450
  • 1
  • 4
  • 16
13
votes
6 answers

Memory: object not release after view controller dismiss, with ARC

I have 2 view controller, FirstViewController - > SecondViewController via [self presentViewController:SVC animated:YES completion:nil]; on SecondViewContrller when I do [self dismissViewControllerAnimated:YES completion:nil]; My question is,…
Bordz
  • 2,810
  • 4
  • 23
  • 27
13
votes
1 answer

ios: how to dismiss a modal view controller and then pop a pushed view controller

I have a view controller B that is pushed onto the navigation stack by root view controller A and this view controller B needs to display an alternative view if its model is in a certain state so it is modally presenting another view controller C.…
Heisenberg
  • 1,319
  • 1
  • 12
  • 15
12
votes
6 answers

What is better place for loading data from API- viewDidLoad, viewWillAppear or viewDidAppear?

I am making an IOS app where i am calling an API in viewDidLoad method of view controller. Now i want to reload the same view controller with the data that comes from server. How many ways are there to do this task and what would be the best way??…
Kirti
  • 573
  • 2
  • 8
  • 18
12
votes
2 answers

ios - Navigation between multiple NavigationControllers

I'm trying to understand a behavior of navigating between ViewControllers with (and without) using a NavigationController and I'm misunderstanding some things while reading articles and docs so I decided to ask them. Main question is: What happened…
Max
  • 404
  • 2
  • 17
  • 39
12
votes
2 answers

Getting appdelegate value from viewcontroller

In Appdelegate.h I imported the playerviewcontroller in both Appdelegate.h and Appdelegate.m files. @class PlayerViewController; @property(nonatomic)float volumeDelegate; In Appdelegate.m @synthesize volumeDelegate; -…
AlgoCoder
  • 1,706
  • 5
  • 19
  • 40