I am beginner in ios development. I created a tab bar controller in storyboard. In one of the tabs, I added a table view with custom cells in storyboard with a map view on top created in code. When user presses on the map view, it slides down pushing down the table view. All is fine except when I go to other tab and come back to the tab, the table view is back up with its frame from storyboard. Can some one suggest how to prevent this?
Related
I am a bit new to iPhone development and working on learning it on my own.
I have a view controller which contains 2 parts:
Image View - some picture + some text on top of it
Container view
the container view is now segued into a new controller view which I replaced with a collection view. The idea here is for this to hold some picture I can click on to get to another page yet.
So, with all that, I have things working fine. My main view shows the top picture + text and below is all the smaller pictures which are clickable and that take me to another view that is being presented modally.
The final view is a UIView that contains in it a imageView to hold the picture I clicked on the other view. This even works fine.
The issue is that I am trying to add a naviagtion bar on top of the new view which shows up fine in story board and I added a button to close it. But that for some reason does not show up when I run the application.
If I change the presenting mode to Push, I see the navigation bar show up with the back button as well, but my close button does not work there either (code added to dismiss the view correctly).
What am I doing wrong with the modal presentation?
If you want to present a view with a navbar modally, it has to have it own NavigationController.
So too have a NavigationBar in a modal displayed View, drag a UINavigationViewController in front of your ViewController, e.g.:
This is not needed in case of a push segue, as the pushed ViewController is still child of the original UINavigationViewController, wich is owner of the NavigationBar
The NavigationBar is managed by the UINavigationController, wich is on the parent-side.
So if you add Buttons in the Storyboard, you are adding these buttons to the NavigationItem, wich belongs to the ViewController.
I created a Single View application with a view controller that allows you to enter homework assignment data. I now am trying to add onto this app by creating a navigation controller. I want the First Screen to be a Table View, that switches to the homework assignment screen when you click the "Add" arrow.
I've created the Navigation controller onto the Table view, and connected the Add button to the Assignment View Controller, but when I start the app, it still opens up to the Homework Assignment screen.
Can anyone provide a simple way to change the startup screen to my TableView?
EDIT: I am using storyboard. I havent added/edited any new code anywhere for the Table view/ Navigation controller/AppDelegate, I just dragged and connected with storyBoard, I just need to app to startup on the table View instead of the Homework assignment View Controller.
In your storyboard, select the view controller that should be the initial one. Go to the utilities view (on the right). Open the attributes inspector. Tick the Is Initial View Controller checkbox.
I created a MasterViewController project with a tableView, now I'd like to add some tabs to this. I tried to just drag and drop the tab bar into the MasterViewController and the tabs show, but they are linked the the last cell in the tableView.
Is there any way to make the tabs stay in place so they are always displayed? What I am trying to accomplish is to give the user buttons to push to organize the data in the tableView, so I'm open to other suggestions.
Here are the pictures:
You need to have your controller be a UIViewController, not a UITableViewController (where the table view is the controller's self.view, and is full screen). If you use a UIViewController, you can add a table view, and size it such that you have room at the bottom to add the tab bar. In that case, both the table view and the tab bar are subviews of the controller's self.view. The way you're trying it, the tab bar is added to the table's scroll view.
It sounds like you added it as a subview of the table view, so as the table view scrolls it scrolls too. Look at creating a container view to hold both the tableView and tab bar / segmented control / buttons positioned below it. You will need to make the controller a subclass of UIViewController instead of UITableViewController.
Alternatively, use the navigation bar to add some edit button(s), either to enter an editing mode which shows controls on each row or where the buttons actually edit the currently selected row.
Tab bars are container controllers and are used to present a different mode of your application. If you want to only organize your tableview data, my suggestion is to use UISegmentedControl.
I'm trying to add a view that is a form that has 3 elements. These elements will be inside of a static grouped table. I need a navigation bar at the top with a "Save" and "Cancel" button. Both buttons should send the user back to their previous screen when tapped.
Within the storyboard, I have tried creating a Navigation Controller and then adding a table to it, but I get the error of "Static table view are only valid when embedded in UITableViewController".
So, I tried creating a Table View Controller, but the storyboard won't let me put a navigation bar into one of those for some reason...
What is the best way to go about doing this?
Add UITableViewController to your storyboard and then choose Editor > Embed in > Navigation Bar Controller from the menu. This will wrap your table view controller in a nav bar controller and you can then add your Save and Cancel buttons to the navigation bar.
It might seem a bit wasteful to create a navigation controller with only a single sub-controller just to get a navigation bar but it's the accepted way of doing it.
Oh... this iOS stuff is hurting my head.
I wanted to do the same thing, have a TableView, with a Navigation Bar at the top, but there was no "Embed in.. Navigation Bar" menu item, just "Embed in.. Navigation Controller".
Eventually, solving this was easier than I thought.
I just needed to add a Table View Controller to my storyboard, then CTRL+drag a Segue from the "calling" view controller to my new Table View Controller, and, voila, it gives me the Navigation Bar straightaway.
I have a UITabBarController that has a list of UINavigationControllers assigned to the 'viewControllers' property.
Each UINavigationController has a custom UIViewController as its 'rootController' and this custom UIViewController loads its 'view' from a .xib file. This 'view' contains a UITableView (and some other controls that are displayed when the data for the UITableView is first downloaded).
It works fine to begin with - I can see the table view for the first view controller when the first tab is selected, changing tabs displays the other table views - all is good.
My problem is, when I select a row on one of these table views a new custom view controller is instantiated, told to hide the bottom bar when pushed and then is pushed on to the navigation controller. Again - this works as expected. I see the new sub-view and the tab bar is hidden.
The problem is when I return to the previous view, the final row in my UITableView is now obscured by the tab bar (which has correctly reappeared). It seems the process of hiding the bottom bar and then showing it again when returning to the previous view has confused things.
Has anyone encountered this? Any idea what I might be doing wrong?
Check that your UITableView has not the UIViewAutoresizingFlexibleHeight (in IB, see the picture below).
alt text http://www.quicksnapper.com/files/5161/20375276064A0C11D2C33A4_m.png