I have a UITableView that when first displayed it displays correctly with the first row appearing on top. When I select a cell another UITableView is presented. If I used the back button on the UINavigation Bar the original UITableView is shifted down with a blank space between the UINavigation Bar and the UITableView.
I am not using story boards. I am using XIB files. I am also using a sliding menu that I got the code for from Ray Wenderlich's web site.
When I slide back the main screen over the first UITableView it goes back to its proper position. But then when I select an entry again the issue described above appears.
I found another post that seems to provide an answer to the issue. This post says to make some adjustments like to the translucent settings or the auto-layout settings but doesn't give specifics.
Here is that post: Container View getting pushed down as if it had a UINavigationBar?
Thanks,
Glenn
Add
self.automaticallyAdjustsScrollViewInsets = NO;
in viewDidLoad, of the UIViewController where you have the shifting table view
Related
I’m working on a project in Xcode 9.1 and a very strange problem occurs with my Table View Controller.
I need to have a table view with static cells and Xcode tells me that I can achieve this only with a TableViewController (doesn’t work with a TableView in a ViewController. Gives me errors).
I’ve embedded my TableViewController inside a Navigation Controller, but when I run the project, the table View scrolls and it’s visible under the status bar (on every iPhone, from X to SE).
I wanted to make the status bar opaque but didn’t find a way to do it.
Am I doing something wrong?
My steps are:
1) Dragged a TableViewController on the storyboard
2) Embed the TableViewController into a Navigation Bar (I’ve tried also to drag the Navigation Bar directly and it comes already connected to a TableViewController).
3) Set the Cells to Static
4) Run on device or simulator.
Screenshot of my problem
Solved it!
The problem was the code I wrote to hide the navigation bar hairline (the 1px line under the bar).
Commenting the code make everything work fine.
To fix your issue I think your Navigation Bar is set to hidden.
1. In your storyboard click on the navigationBar in the navigation controller.
2. Then look for the attributes section "Drawing"
3. Check to see if hidden is true.
4. If it is uncheck it.
My setup has it set to false as default.
to hide navigation you need to write below code in viewDidLoad
self.navigationController?.isNavigationBarHidden = true
I am using a navigation controller and within that navigation controller, I have a VC with a tableview that is hugging the top, bottom, left and right sides of the superView. When I have self.navigationController?.navigationBar.prefersLargeTitles set to false, everything works fine. But when I set it to true, I have to drag really really far down to get my refresh controller to trigger the refresh.
This is fixed by simply tapping one cell which then goes into the detail view and then pressing the back button from the detail view to go back to the vc with the main tableview and refresher. After doing that the pull to refresh works perfectly with the large titles. Very weird!
I have a very basic setup of my tableview. My actual project has a more complex setup but in order to isolate this problem, I created a much simpler project with the same tableview and the issue persisted. Has anybody else seen this issue? I am thinking it is an issue on apple's end but I wanted to check if I was doing something wrong on my end.
I am using swift 4 and iOS 11.0.2 with Xcode 9.
The animator starts to animate but when it gets a certain (the point where it should refresh), it just stops. When I keep on pulling down further and further, it does the refresh. But it should have done it much earlier. I have to pull down to the point where the nav bar stretches to almost the entire length of the screen. See the screenshot.
you can try to set self.extendedLayoutIncludesOpaqueBars = YES;
You try this by adding the constraint of tableview.top to View.top of ViewController instead of topLayoutGuide
I would like to use a UISearchBar and put it towards the bottom of a screen in order to search for available names through an API call. I want to have this SearchBar as part of a sign up form. However, when I put the SearchBar on the screen where I would like through the Storyboard, it does not show up when I run the app on the simulator. When I looked up this issue, everyone is putting the searchbar in a tableview. Am I not using the correct UI element for my cause?
The reason your search bar is not on the screen is probably because you didn't set constraint correctly or it was hidden or covered by some other view.
And for your second half of the question, I myself never put a search bar on a UITableView itself. Some apps put a search bar on the first cell of a table view but you have to scroll to make it show up. I myself always prefer to put it on the navigation controller on the top of the screen so that it will always be there and ready for user to search anything.
This issue has had me stumped for a few days.
This is my relevant storyboard layout:
I have set every layout under the sun to all three View Controllers and still get a resultant Table View with a "gap" above the Banner View - seemingly the same height as the Banner View. As follows:
One thing that did work was to drag the Container View over the bottom Banner View like this:
And the result renders perfectly on my test device as well as every simulator - i.e. no gap.
But such a solution is essentially a hack of sorts and I'd like to see if there is anything I can do to properly fix the issue.
For the record, I have tried every option in the IB - adjust scroll view insets, extend edges under top/bottom bars, etc... as well as various code snippets I have googled here and there. Nothing seems to solve the issue for me.
I managed to solve the gap at the top of the table view under the nav bar (seemingly a common issue with a lot of content out there). But there does not seem to be so many cases like mine above.
Any help or indications are greatly appreciated. Thank you people :-)
* ADDITIONAL INFORMATION *
As per a comment below, I add the constraints I have tried for the said container:
I had similar gap problem, when used ContainerView to embed StoryboardReference - to support StoryboardReference from UITabBarController on iOS8.
I have resolved this by turning on Extended Egdes -> Under OpaqueBars checkbox on view controller with container view, like on image:
The red UIView is ContainerView, first ViewController in StoryboardReference is UINavigationController.
OK. Essentially, with the kind assistant of #beyowulf I realised my current setup had to be changed.
I was
unnecessarily using a container view in your tabbarcontroller
as he correctly indicated
there is no way for your table view controller to infer it's in a
tabbarviewcontroller.
In order for my table view controller to be flush with the bottom of the container view, I had to
directly embed your navigation controller in your tabbarviewcontroller
and adjust the bottom inset of your table view.
I did this via the top menu bar items:
Select the TableViewController
Editor > Embed in - - - > Tab Bar Controller.
You can easily incorporate a navigation controller into the storyboard thereafter if you wish to do so, which I did also.
A handy tip and one I followed to solve my 'gap' issue appearing above the bottom tab bar.
Hope this helps anyone who might also be facing the same issue.
Thanks again to #beyowulf.
I'm developing a simple UI for an iOS app.
what I've done is I developed it into a table view which has a navigation controller associated to it and had it laid out in Storyboard.
Everything seems working fine, except the navigation bar accidentally cover the view's title bar "Click to select item" as shown in the pictures below.
the first picture is when it first shows on the screen.
the second one illustrates when I drag the title bar off the covering navigation bar.
what do i do to get completely rid of this?
In Interface Builder, select your view controller and on the attributes inspector turn off Layout: Wants Full Screen. Then, your layout will automatically adjust its size to make room for the navigation bar.
Add this code in your viewDidLoad method
self.navigationController?.navigationBar.translucent = false
It works for me, since you've the same problem with me, I think it's work for you as well.
where u want hide navigation bar use this line
self.navigationController.hidden = YES;