Views causing Storyboard Issues - ios

Using views within my application is causing my storyboard to do strange things. This is making it very difficult for me to make changes. I thought the issue was due to the fact that using a view limits the size of your next view and so on.
However, it's now causing issues where I have to move tableviews into strange places to make them display correctly on the device.
These views both display correctly on my device. However the view at the top is only half the screen. There is also a navigation bar throughout the app which can no longer be seen on my storyboard.
The first view was fine until earlier today when it randomly began displaying as seen below.
Has anyone had this issue before and know how to fix it?

Related

UISearchController's UISearchBar shifts incorrectly and jumps when UITableView is scrolled

In the video, it's a little difficult to see what's going on, so I'll try to explain it.
https://youtu.be/yOrCJB9yZlg
I have UIViewController with UITableView inside its root view. Binded via Autolayout (there is no difference how it's binded: to SuperView or to SafeArea).
SearchBar added like this:
let search = UISearchController(searchResultsController: nil)
self.navigationItem.searchController = search
When I slowly scroll table, the transition between large navbar and compact navbar, and then animation of showing in and out of searchBar is too fast. Searchbar jumping in/out of navbar instead of smoothly opened/closed; navbar transitioning is jumping between two states, large and compact, without smoothly passes through the middle half-opened state while you slowly moving your finger on screen, like in system apps (Mail, Phone, Messages, Contacts etc).
I made the example from an empty project to demonstrate the issue; there isn't any changes to navigation bar logic, or any logic at all. Just two new VC's and this odd behaviour.
If i create xCode's "Master-Details" project example and add UISearchController to it, it will work properly. I assume its because they used UITableViewController instead of UIViewController + UITableView inside.
What the reason of this behaviour and how to fix it?
I had the same problem with the search controller transition and tableview.
like this its flickering or tableview was jumping. The search controller was on the navigation item.
The key solution is to remove safe area guide from your view controller and assign top bottom left right constraints to your tableview. It will be smooth like this
What you have done is correct. Did you try running your code in a device? Feels more like a glitch in the simulator. I tried what you tried and it works fine for me in the device. Whereas the glitch occurs in simulator.
Refer to this article. They have explained step by step process.
This is a known problem and your code seems fine. This problem was already discussed here.
Problem appears when you're using UIScrollView or its subclasses with large navigation titles. It doesn't work. Problem disappears when you use UICollectionViewController or UITableViewController instead.

Table view is empty - there's an image view from somewhere at the front of the view hieararchy

I was puzzled why my table view is completely blank, despite the fact it should contain content. So I expanded the view hierarchy and can see there is some image view at the front:
See how there's a blue bar the far right of the diagram - thats an image view:
What is this and how can it be there? Its not part of my view controller, and I'm not doing anything like inserting views at runtime or anything, its just a regular table view all done via the storyboard. How can I find out what this is and how its getting there?
But apart from wondering what it is, its not covering the table view, so what reasons could there be for nothing being displayed? As can be seen there's content there in the hierarchy yet there's nothing at all visible in the table view - I just get the red nav bar with white screen below it.
I suspect I won't be able to get an answer to these issues directly, but if anybody has any debugging tips for finding out where this image view is coming from, or how to analyse and debug the hieararchy they'd be appreciated.
Damn you XCode, wasted a couple of hours of my life.
All I did was exit XCode and relaunch it, and lo an behold it suddenly started working.

Can't select view controller or cells on iPad simulator

I'll try to keep this short and sweet. I have a universal storyboard and my application runs perfectly on the iPhone. I'm having an issue though where I have a view controller with 2 containers, which contain separate tableviewcontrollers.
On the iPad simulator the top table view controller works fine yet the bottom will not scroll or select any cells. Again, it works perfectly on the iPhone simulator.
I cannot for the life of my figure out whats causing this. Anyone run into something similar?
Thanks
Your view might be covered by another view. To make sure your view stays in the front, you can use
[self.view bringSubviewToFront:yourView];

Table View with extra View. View keep resizing to maximum

I have a tableview, that is working fine. I have added a view to the top, so I can add some extra fields. I can't post images yet, so going to try and describe.
Navigation Bar
View
TableView
When I build it, it looks good.. However when I run or close the project and reopen I get this:
Navigation Bar
View
TableView
With the view taking up the complete page, pushing the TableView to the very bottom.
Any thoughts on why this is happening and how to fix it?? I can resize it back to the size I want using the size inspector, but it doesn't keep the value.
I have built a test project with the same screen layout and it works perfectly. I can't see what is different between the two projects is. Thanks
Yes, this was an auto layout problem.. After looking around the web, and trying various solutions I decided to use a view controller, and add my own tableview and tablefviewcell to that, along with my other labels and buttons. Once I built the methods the first time, I found this to be much cleaner solution, than attempting to mess around with the tableviewcontroller.

iOS Custom View Controller

I am trying to have the ability to switch views in and out. The screens are generated on the fly and there may be anywhere from 30-100 of them that will be presented sequentially. A NavigationController may work, but I may be creating a hundred or so screens so I am worried it will run out of memory if I push that many views. Maybe this could work if I only ever added one screen at a time to the NavigationController, and when a new one is added remove all screens and then add the new one. But this may cause strange animations.
I tried creating a custom View Switcher that could load each of the views on the fly following the chapter 6 example in the apress book. The problem is that on rotations the events do not make it to the View Controller for the currently visible view. So it ends up doing weird things on screen rotations.
Another approach that I am thinking may work is to use a tab bar controller and make the tabs invisible. Then I can just use tabs 1 and 2 to hold the current view, and the last view and ping pong back and forth. Then memory is not as much of an issue as using a NavigationController.
Does anyone have any other ideas? I feel like there should be an easier way to do this that I am just not seeing.
How about creating a singleton "ScreenManager" that loads, adds and removes your views on your root view controller? This way you can make sure that the view hierarchy isn't convoluted and out of your control. It's also a good idea design-wise and should be very easy and efficient with memory management.

Resources