I am currently learning iOS development and I began with a simple Tabbed Application. It has the default First and Second View in it. I added a TableView with static cells content. I then added another View Controller. I created a Segue using the storyboard. When I set the transition to modal, it works fine. When I set it to push, the app is crashing (Uncaught exception).
Any idea why?
How can I get more information regarding the exception? Can I make the app stops when it encounters an exception?
Figured it out.. I need to add a Navigation Controller to use push...
Related
I am trying to build an app, and I want another view to open up once I click a button. I have searched for an answer, but nothing came up. I already have the button done, but I don't know how to get another view to show up. The view should be another view within the app. I am just a beginner in xCode. Thanks.
I am currently using xCode 9, and swift 4. Thanks.
You can approach this either using the storyboard or programmatically. Using the storyboard, you can ctrl-drag from the button to the other view controller and the segue will be wired up for you, like so:
If you aren't using storyboards at all, you can use the .show method of the ViewController in the button action. Apple has a good guide on segues.
I have a bug in my code that I hope some can help me with.
I have a UIPageViewController in my storyboard and I am also using a UINavigation Controller. When my segue is run which connects one view to switch to the uipageview the viewdidload method gets called on the uipageviewcontroller twice.
Weird thing is it only happens on the iPad the same code on the iPhone only gets called once. Does anyone know why that would happen?
Seems to have been a bug in iOS. When I updated my OS the problem was fixed.
I am having a minor problem with segue using push in Xcode's storyboards. Its pretty straightforward: even with the simplest case, I can't manage to get it working.
The setup: http://d.pr/i/ahCG
Which is basically just a 1-view project, added another view controller, embedded that into a navigation controller and made the segue and setting the mode to "push". There is absolutely nothing happening when I push the test button. If I make the segue with modal however, it works fine.
What am I doing wrong?
You need to embed the source view (not the destination view) into a nav controller to do a push segue.
You need to set the mode to "modal" instead of "push".
I'm trying to develop an iPhone app that uses 4 views(View-based app), and I want to navigate from one view to the other. It would be ideal if for example the Submit ID button automatically sent a message to UIViewController to switch to View 2, and selecting a cell in View 2 would load View 3.
See a screenshot of the Storyboard here.
I'm not sure how to do that, so I've tried using a separate button to switch between views, but that isn't working either and I can't figure out why.
You can have a look at the source code which I've uploaded to Dropbox.
First, I would suggest posting your code in your question. As appreciative as I'm sure other people are that you provided a dropbox link to the code, most people presumably have little interest in downloading the file to their computer, unzipping, and launching the project (me being one of them).
That being said, let's make sure you're clear on Storyboards and the general view controller hierarchy principles. You have, in your storyboard, four UIViewControllers dragged out into your workspace. So, you're not switching the views of a single UIViewController, telling it to switch from View1 to View2 to View3 and so on. You need to be telling the view controller hierarchy (which, in your case, probably needs to be managed by a UINavigationController), to push and/or pop view controller on and off its stack. It appears that you have some segues set up between your view controllers. Are you calling performSegueWithIdentifier:sender: in your code? Alternatively, you could hook up the Submit ID button to perform a push segue to View Controller 2 in much the same manner.
Once you have that working, you can override prepareForSegue:sender: to send information from ViewController1 to ViewController2 and so on.
I have an app where the appDelegate has a UITabBarController. Each of the tabs has a navigation controller which I currently use to push a single detail view onto the stack in each tab. I am hoping to replace my navigation controller on each of the tabs with a splitViewController. I use the Interface builder to provide the UINavigationController for each tab. I am having trouble loading a nib for each tab that has a UISplitViewController in it. I am getting an instance of the UITableViewController class displaying on the screen, but I am not getting the UISplitviewController or the Popover or the detail view etc. These classes are all working in a standalone app, but I am not able to get them into each of the tabs in one app. Although I am currently using the Interface Builder I am open to doing this programmatically. If someone has suggestions, or an example small project of a Tab based app with individual split views in the tabs I would appreciate it very much. (As this is my first question I am not sure how much code or other pictures from IB would be helpful for me to post. If you need further detail please let me know and I would gladly amend this post.)
Apple documentation
"The split view controller’s view should always be installed as the root view of your application window. You should never present a split view inside of a navigation or tab bar interface."
Moving on...
Not only shouldn't you -- if you do so, an error is thrown when you run. It's impossible.