Questions tagged [viewcontroller]

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

viewcontroller
Filter by
Sorted by
Tagged with
649 votes
28 answers
345k views

Presenting modal in iOS 13 fullscreen

In iOS 13 there is a new behaviour for modal view controller when being presented. Now it's not fullscreen by default and when I try to slide down, the app just dismiss the View Controller ...
pascalbros's user avatar
  • 16.4k
244 votes
20 answers
407k views

How to dismiss ViewController in Swift?

I am trying to dismiss a ViewController in swift by calling dismissViewController in an IBAction @IBAction func cancel(sender: AnyObject) { self.dismissViewControllerAnimated(false, completion: ...
rshankar's user avatar
  • 3,075
107 votes
16 answers
95k views

In iOS, how to drag down to dismiss a modal?

A common way to dismiss a modal is to swipe down - How do we allows the user to drag the modal down, if it's far enough, the modal's dismissed, otherwise it animates back to the original position? ...
foobar's user avatar
  • 11.2k
100 votes
8 answers
257k views

Swift programmatically navigate to another view controller/scene

I'm using following code to programmatically navigate to another ViewController. It works fine, but it some how hides the navigation bar. How do I fix this? (the navigation bar is created by embeding ...
Victor's user avatar
  • 1,623
97 votes
3 answers
67k views

iOS Nested View Controllers view inside UIViewController's view?

Is it typically bad programming practice in iOS to have a nested view controller's view inside UIViewController's view? Say for instance I wanted to have some kind of interactive element that responds ...
Skyler's user avatar
  • 2,864
95 votes
11 answers
151k views

Programmatically switching between tabs within Swift

I need write some code to switch the view to another tab when the iOS app starts (so, for example, the second tab is shown by default rather than the first). I'm new to Swift, and have worked out the ...
Oliver Spencer's user avatar
93 votes
16 answers
309k views

How to Navigate from one View Controller to another using Swift

I'd like to navigate from one view controller to another. How can I convert the following Objective-C code into Swift? UIViewController *viewController = [[self storyboard] ...
sathish's user avatar
  • 1,180
88 votes
2 answers
111k views

How do I create a view controller file after creating a new view controller?

I am developing a tabbed application. When I create a new view controller and link it to the tab bar controller, unlike the other two default view controllers, this one has no viewcontroller.swift ...
Kian Cross's user avatar
  • 1,818
84 votes
14 answers
219k views

Swift presentViewController

I programatically have multiple View Controllers in an iOS Swift Project. I do not have the storyboards and would like to avoid them if possible. Is there a way to switch to another viewcontroller....
Z-Tech's user avatar
  • 4,430
81 votes
5 answers
123k views

presenting ViewController with NavigationViewController swift

I have system "NavigationViewController -> MyViewController", and I programmatically want to present MyViewController inside a third view controller. The problem is that I don't have navigation bar in ...
Yury Alexandrov's user avatar
68 votes
14 answers
107k views

Loading ViewController from xib file

I had a MyViewController.swift and a MyViewController.xib presenting the layout of MyViewController. I tried different methods to load this view controller including: //1 let myVC = UINib(nibName: "...
bluenowhere's user avatar
  • 2,713
60 votes
7 answers
93k views

Xcode - How to connect XIB to ViewController Class

I created first my TestViewController.h and *.m. Afterwards my TestView.xib. Now I need to tell my xib: "Yes, please take the class TestViewController as my File's Owner". I open up my xib, go to ...
mogio's user avatar
  • 843
51 votes
10 answers
47k views

Dismiss more than one view controller simultaneously

I'm making a game using SpriteKit. I have 3 viewControllers: selecting level vc, game vc, and win vc. After the game is over, I want to show the win vc, then if I press OK button on the win vc, I want ...
codeinjuice's user avatar
47 votes
5 answers
49k views

Only ONE VIEW landscape mode

I finished my iOS app but I need to set only ONE view to landscape mode, the rest of the views can only be seen in portrait mode. I'm using Xcode 5.1 and I created all of my Views by dropping in my ...
maeq's user avatar
  • 1,103
47 votes
9 answers
172k views

Swift: Reload a View Controller

I need to refresh a view controller when a certain button is tapped. Simply activating viewDidLoad() does not seem to be working for what I need to do. However, when I leave the view controller and ...
Matt Spoon's user avatar
  • 2,800
43 votes
7 answers
106k views

Cannot call value of non-function type 'String'

I'm trying to pass the ILTItem variable into my ILTViewController, triggered by AppDelegate.swift when the user launches my app via a deeplink. The code I have errors with: Cannot call value of ...
James's user avatar
  • 1,108
33 votes
1 answer
26k views

Equivalent of Fragment (Android) in iOS

I want to know if there is a way to use some view controllers within a view controller which provides the same functionality as Fragments in Android? I want to use custom view controllers so I do not ...
Sarasranglt's user avatar
  • 3,839
31 votes
6 answers
21k views

How to Sign Out of Google After Being Authenticated

So my app has the option to sign in with Google. Upon clicking the button that Google provides, a web view opens and has the user input their credentials. After allowing the app to access their ...
About7Deaths's user avatar
28 votes
2 answers
37k views

Adding swift file to new view controller in xCode? (easy)

I'm just starting out in xCode 6, and I can't seem to figure out how to add a new swift-file to the new view controllers I add in the interface builder. Any tips on how to proceed would be ...
martin's user avatar
  • 1,934
27 votes
1 answer
11k views

Difference between a Scene and a View in iOS

I'm new to iOS I'm having trouble understanding the difference between scene and a view. Unfortunately Apple's documentation isn't helping me. I read that a scene is what you see on the screen. But ...
CGTheLegend's user avatar
26 votes
5 answers
19k views

UIScrollView prevents touchesBegan, touchesMoved, touchesEnded on view controller

I am handling touches for a couple of my UI components in my view controller (custom subclass of UIViewController). It has methods touchesBegan:withEvent:, touchesMoved:withEvent:, and touchesEnded:...
morningstar's user avatar
  • 9,078
25 votes
2 answers
25k views

Difference between presentModalViewController and presentViewController?

In iOS 5 SDK, there're two methods of UIViewController, presentModalViewController:animated: and presentViewController:animated:completion:. What's the difference between these two method? The ...
YuAo's user avatar
  • 1,427
21 votes
12 answers
41k views

setValue:forUndefinedKey:]:

FinalViewWithSending *newView = [[FinalViewWithSending alloc]initWithNibName:@"FinalViewWithSending" bundle:nil]; newView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self ...
Szwedo's user avatar
  • 364
21 votes
3 answers
44k views

Open Specific View when Opening App from Notification

I have just added push notifications to my app. I'm wanting to have so that when a user opens the app from a notification, it will open a specific view controller and not my rootViewController. Here ...
raginggoat's user avatar
  • 3,600
21 votes
4 answers
36k views

Swift: How to access in AppDelegate variable from the View controller?

I would like to write in the text or csv (prefer) file the variable from the view controller. Indeed I am doing a drawing app and I would like to write in the file the current position of the finger....
Yann Amouyal's user avatar
19 votes
3 answers
5k views

Deleted class drops error message unknown>:0: error: no such file or directory:

So me and some friends working on a bitbucket project and already realized that bitbucket sometimes doesn't sync all the files. But here is what happened: I continued working and created an class, I ...
makle's user avatar
  • 1,257
18 votes
4 answers
26k views

iOS - Toolbar not showing

Using the storyboard I created a new screen for a second View controller and added a Toolbar at the bottom. But when the view is shown, the toolbar doesn't appear. I'm using Segue to change views. ...
Mauricio Zambon's user avatar
18 votes
2 answers
25k views

How to create a confirmation Pop Up when pushing Back button in iOS?

I want to add a pop up when someone pushes the "Back" button of my iOS App, to ask the user if he really wants to come back. Then, depending on the user's response, I would like to undo the action or ...
recasens's user avatar
  • 331
17 votes
2 answers
22k views

Class has no initializers: Swift Error

I have a problem with my ViewController. My code has an error about initializers and I can't understand why. Please, take a moment to look at my code: import UIKit class ViewController: ...
iGermanos's user avatar
  • 181
17 votes
3 answers
14k views

Understanding View Controller Nesting in iOS

Ive been tearing my hair out over the last couple of days trying to understand this one seemingly basic concept of iOS development: If I want to have two or more View Controllers displayed and usable ...
Adam Eisfeld's user avatar
  • 1,444
16 votes
4 answers
37k views

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 ...
Aleric's user avatar
  • 301
15 votes
6 answers
8k views

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 ...
classicalpianoguy's user avatar
15 votes
2 answers
17k views

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 self....
Doto Pototo's user avatar
15 votes
2 answers
47k views

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 ...
Michel Kansou's user avatar
15 votes
2 answers
52k views

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 ...
Magesh's user avatar
  • 277
15 votes
3 answers
12k views

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 ...
Jell92's user avatar
  • 183
14 votes
3 answers
20k views

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 ...
Legolas's user avatar
  • 12.2k
14 votes
2 answers
8k views

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 ...
Robert Marlan's user avatar
14 votes
5 answers
17k views

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! ...
Yury Alexandrov's user avatar
13 votes
4 answers
23k views

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(...
Vasil Nunev's user avatar
13 votes
1 answer
8k views

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 ...
Heisenberg's user avatar
  • 1,319
13 votes
6 answers
19k views

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 ...
Bordz's user avatar
  • 2,810
12 votes
2 answers
26k views

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....
AlgoCoder's user avatar
  • 1,706
12 votes
6 answers
16k views

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 ...
Kirti's user avatar
  • 583
12 votes
2 answers
12k views

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 ...
Max's user avatar
  • 444
11 votes
3 answers
10k views

Pass data from ViewController to Representable SwiftUI

I am doing an object detection and used UIViewControllerRepresentable to add my view controller. The thing is that I can't pass data from my ViewController to my SwiftUI view. I can print it tho. Can ...
Yonus's user avatar
  • 233
11 votes
4 answers
18k views

Swift passing calculated data back to previous view controller

I am creating my first simple budgeting app. Basically, I take a few user inputs like monthly income & savings goal. Then they click "start", & the app calculates stuff such as, their daily ...
Coding while Loading's user avatar
11 votes
5 answers
12k views

How to reference the current Viewcontroller from a Sprite Kit Scene

I'm having a hard time finding the answer to this question I assume is not that hard. How can I reference methods and properties defined on a viewcontroller from a SKScene ? And building on that: ...
stvn's user avatar
  • 1,148
11 votes
5 answers
18k views

How can I remove a view from navigation controller

I want to call a new view controller and remove the current view controller from the navigation controller stack. For example. I am in view controller A and I call B. Now I have in the stack A , B. ...
Tony's user avatar
  • 10.2k
11 votes
2 answers
18k views

How to access ObjectAtIndex in tabBarController with Swift?

i used to say in obj-c [self.tabBarController.viewControllers objectAtIndex:1]; but now in swift no ObjectAtIndex any more self.tabBarController.viewControllers.ObjectAtIndex Update ok i am ...
Amr Mohamed's user avatar
  • 2,340

1
2 3 4 5
56