I have a UICollectionView that scrolls with a bunch of images and I want to have a pinned Navigation Bar on the top that stays there even as you scroll. I moved the cell down in the UICollectionView in order to make room for a navigation bar and I dragged one into the View. I can see it in my story board however it is just a black view when I run the app. Can anyone please show me how to make this nav bar appear and how to make it stay pinned at the top even as you scroll. Thank you so so much. (I tried to attach photos of my problem but it says I do not have enough reputation to post images) I hope you guys are able to understand my problem and direct me in a way in which I could add a navigation bar that stays pinned on the top of a CollectionViewController
Drag a navigation controller into your storyboard. You probably want to position it just to the left of the view controller that has the collection view.
Delete the view controller that Xcode automatically attaches to the navigation controller.
Right click on the navigation controller and drag from root view controller over to your view controller where you have your collection view.
If necessary, move all segues that went to the collection view to the navigation controller instead.
Related
This issue is something I have been struggling with for a while and have been able to get around for the most part by using was seem like hacky techniques but I am needing a better way to accomplish this now.
My question is how do you add UI elements above a table view (in a table view controller) and make them stick to the view (the should not scroll with the table view). For example adding a navigation bar is simple because you can just embed in a navigation controller to the table controller. But what if you want to add say a tab bar below the navigation bar but above the table view? So that the table view scrolls and the tab bar sticks to the bottom of the navigation bar and does not scroll with it.
Ive tried to do this by placing it in the storyboard just below the navigation bar and just above the tableview but it just scrolls with the table.
Any help on this is very much appreciated!
The image shows the View controller and the bar I want to remove. And also the structure of the view controller:
Someone told me how to remove the grey bar present at the bottom of the view controller as shown in the image. Unable to select and delete the bar. When I try to add the tab bar in that place, it goes behind the grey bar and becomes invisible.
What do your simulated metrics look like?
Can you get rid of the bar by changing the bottom setting?
Couple of things - if you are using autolayout, just make a constraint to the bottom of the container, with 0 value for the constraint. That will take it to the bottom. Second thing I would add is a zero size table view footer to the tableview.
This is a toolbar that comes with the UINavigationController that the View Controller is embedded in. Assuming you have a Navigation Controller on the storyboard connected to the view controller, select it and in the attributes inspector deselect "Shows Toolbar". If you want to do this in code you can get and set isToolbarHidden on a UINavigationController instance.
Hi guys I got situation where in if I embed NAVIGATION CONTROLLER to VIEW CONTROLLER containing table view, their is some gap gets created between NAVIGATION BAR and PROTOTYPE CELL.
Even if I drag and drop NAVIGATION CONTROLLER to canvas and delete its ROOT VIEW CONTROLLER and connect it to the VIEW CONTROLLER containing table view as ROOT VIEW CONTROLLER, then also the same situation occurs. I even try changing the height values of PROTOTYPE CELL but the same thing.
photo link https://db.tt/up0sZypj
This situation doesn't occur only when I directly uses NAVIGATION CONTROLLER with its own ROOT VIEW CONTROLLER.
photo link https://db.tt/JssxrNbe
So please help me out of this situation.
I have given photo link because I can't attach photos as I don't have 10 reputed posts, am really sorry for that.
Try this may help you.
Uncheck option for ScrollView inset for UIViewController in which your TableView resides.
You probably have the top constraint of your tableView set to the top layout guide and have extended edges under top bars enabled.
If so you can either remove the top constraint and drag the top of your tableView to top of your superview; underneath the navigation controller. Then set the top constraint to 0 to the top of your superview.
or
You can uncheck the extended edges under top bars checkbox in the attribute inspector when the UIViewController is selected
I am trying to add a UIImageView to the back of a navigation bar.
The reason is because I want to create a UITableView whose navigation bar is actually a picture (with back button on the left) but I want the picture to scroll with the tableview and when the picture is fully scrolled out. The navigation bar is shown as per normal.
My solution to this problem:
Add a UIImageView to the top of the UITableView and make the navigation bar transparent. Set a contentOffset for the UITableView which is a subclass of UIScrollView so that when the view is presented, it looks like the picture is filling the navigation status bar.
Problem:
If I scroll up, instead of bouncing back, the transparent status bar is shown (with a color of the background as it is transparent).
Possible way to solve this new problem:
I was thinking of trying to limit the ScrollView size to get around with problem but failed.
So I feel is it possible to add the UIImageView to the "back" of the navigation bar so that it is there without any offset? Since that way, my life will be much easier.
Any suggestions on solving this or another new approach to get the same UI/effect?
Related question.
I would do this by adding either a table header or cell at the top of the table which contains your image.
Create the table view so that it extends all the way to the top of the screen. Extend Under Top Bars option. I have not done this with a UITableViewController but I have done this with a UITableView embedded inside a UIViewController's view with the top constraint set to 0 for the view rather than the top layout guide.
Now when you run this your table will fill the whole screen and the top header or cell will be at the top showing your picture.
When you scroll you can either use the UIScrollViewDelegate to detect the movement or implement tableView:didEndDisplayingCell:forRowAtIndexPath:
I'm not 100% sure when you want the navigation bar to go non clear. If its when the image goes off screen then didEndDisplayingCell should be good. If its when the cell bottom passed under the bottom of the navigation bar then scroll view might be your only option.
This will also bounce as you expect when you pull down and it should snap back to the top.
Hope this helps.
I have a table view controller in my app. I have many table view cells in it. When I scroll down in the table view, the toolbar/navigation bar disappears. When I scroll back to the top of the screen, it is visible again. Please tell me how to have the toolbar/navigation bar visible at all times.
refer below link, it may help you. It's an example of simple navigation controller with UITableView:
http://www.techotopia.com/index.php/Creating_a_Navigation_based_iOS_5_iPhone_Application_using_TableViews