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
11
votes
5 answers

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. Now I want to call C (from B). I want the stack to…
11
votes
3 answers

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 someone help me? This is my code: // import…
Yonus
  • 233
  • 2
  • 12
11
votes
4 answers

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 budget etc. Here I'm running into trouble. After all the…
11
votes
2 answers

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 gonna make it simple lets consider i have…
Amr Mohamed
  • 2,290
  • 4
  • 20
  • 39
11
votes
5 answers

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: How can you reference the ViewController from a…
stvn
  • 1,148
  • 1
  • 8
  • 24
11
votes
4 answers

Changing root view controller after iOS app has loaded.

In order to show my login screen when the app loads, and not after the user logs in, I have decided to add an auth object in NSUserDefaults when the user logs in successfully. When the app is launched that auth parameter is checked, and the view…
Misbah Khan
  • 372
  • 2
  • 3
  • 12
10
votes
3 answers

iOS app freezes after dismiss view in swift

My issue is this I have two viewControllers connected with a modal segue like normal A--->B, A has the controls like textFields, switches, buttons and a mapView where I get the userLocation. B hast only a button, and a mapView at the moment, but…
Pedro.Alonso
  • 1,007
  • 3
  • 20
  • 41
10
votes
3 answers

force landscape ios 7

I've tried to following methods to force landscape on one my views: - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return…
diogo.appDev
  • 1,595
  • 5
  • 16
  • 30
10
votes
4 answers

Unable to select custom class for ViewControllers in Xcode Storyboard

I just upgraded Xcode to 5.0. I'm still fairly new to cocoa so I hope I'm overlooking something basic. Basically I can't get Xcode to see the custom classes that I want to use as parent classes for view controllers. Originally I wanted to create a…
garma
  • 213
  • 1
  • 3
  • 12
10
votes
3 answers

Force landscape for one view controller ios

I've looked at several answers to questions similar but none of the answer worked. I have an app where I need everything portait except for one photo viewer I have. In the supported orientations section of the targets menu I only have portrait. …
9
votes
5 answers

How to present a second ViewController & dismiss the first

using the following code in the parent ViewController, I want to present a second view ontop of the first, then dismiss the first: // Animates the next questionViewController using the first questionViewController [previousView…
Tim Windsor Brown
  • 4,069
  • 5
  • 25
  • 33
9
votes
1 answer

Switching Views Programmatically in Swift

I am trying to switch to the second view by pressing the "feeling lucky" button. When I try out my simulator and press it, it just goes to a black screen. How could I fix this? @IBAction func FeelingLuckyPress(sender: UIButton) { let…
SRL
  • 195
  • 1
  • 2
  • 7
9
votes
2 answers

iOS: How do I swipe between views using Swift

I'm new to Swift and iOS development, and am looking how to set up a main view where I want swipe right for a second view or left for a third view. When I am in the second or the third view it should be possible to swipe back to the main view. I…
LilK3ks
  • 205
  • 2
  • 3
  • 14
9
votes
5 answers

(Swift) PrepareForSegue: fatal error: unexpectedly found nil while unwrapping an Optional value

DetailViewController: @IBOutlet var selectedBundesland: UILabel! TableViewController: override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { if (segue.identifier == "BackToCalculator") { var…
Velocity
  • 169
  • 2
  • 8
9
votes
2 answers

Passing data received from a push notification from the AppDelegate to a ViewController

In my app, there's a collection view displaying a set of images retrieved from a web service. Each image has tags. So the app has the ability to filter images using tags as well. Now I'm trying to add push notifications to this app. A push…
Isuru
  • 30,617
  • 60
  • 187
  • 303