ViewController not responding to touches - ios

I have a ViewController in which there is a navigation bar, toolbar and a tableview. I have pinned the navigation bar to top, left and right and fixed the height. I have pinned the toolbar to bottom, left and right and fixed the height. I have pinned the tableview to top, bottom, left and right. Now not even the item bar buttons nor the TableViews respond to touches. I have added a screenshot for the same.I have checked and have added the actions and outlets right.My other views are working perfectly fine.

You should have provided with some code.Once I faced the same problem.Then after some brainstorming I found that the problem was in my code,not view controller.I added some code to find latitude and longitude,turns out that gps kept searching location continuously in the background and for that reason,nothing in view controller responded to touch.

Related

How to anchor an UIView to the bottom of layout (with in-call status bar)

Created a custom tab bar and while trying to anchor it to the bottom of my UIViewController found that the in-call status bar moves the bottom anchor weirdly.
To demonstrate my problem, I create a fresh iOS project, put an label in the Main.storyboard and constrain it to the view's bottom.
Then, when I run the project and toggle the in-call status bar, this happens (label in bottom left corner)
Searched already 2 days on the internet for an answer, but couldn't find anything which is relatable... I get it that the view gets resized, but I would still expect that my label shouldn't move. So is there a way to disable this choppy resize movement or how does the UITabBarController, with its TabBar, avoid this?

Hide Bottom Bar When Pushed through Autolayout

I have a UITabBarController with one UINavigationController holding a UIViewController as root view controller.
when tapping one of the button in the UIViewController, I push a regular chat window UIViewController (with TableView + Input View) end hiding the bottom tab bar. (using the "Hide bottom bar when pushed" flag)
In storyboard I added a regular UIView subclass to VC that look like a bottom bar, and I use Auto Layout to pin it to the bottom of the VC view.
The problem
when I push VC it takes a second for this view to pin to the bottom, it looks like auto layout pin it to the bottom as if the tab bar is not hidden and after a sec it recognise that the tab bar is hidden and moves it to the real bottom of the view.
For clear info check this screen shot
Now I will let you the know the constraints of the table view..
Now I am showing the constraints of the InputView
I am also adding my View hierarchy...
I had a similar issue in my project. I solved it by selecting the view I wanted anchored to the bottom (in your case, the input view), held Command, and selected its superview (both views should be highlighted now).
Then I selected the align button at the bottom of IB:
And added a Bottom Edges constraint.
What I had done initially is used the pin menu to pin the view to its superview, but it appears that will pin it to the bottom layout by default, which causes that weird movement during the transition.
EDIT:
After seeing the latest screenshot, the problem could lie in one of the superviews. I'm assuming that chatWindow is a UIView, and your Scroll View is horizontal only. Here's what your should check:
chatWindow is pinned to the scrollView's bottom similar to what I've outlined above.
scrollView is pinned to its superview as I've outlined above.
Moving the inputView outside of the scrollView to the root superview. Then one by one move it down the hierarchy towards its current location.

view shifts down after being presented on screen when hiding tabBar in a navigationController stack in iOS

I am trying to hide my tabBar when pushing to a new viewController. I achieve this by ticking Hide Bottom Bar on Push in storyboard. The problem is that the new view that is being pushed to momentarily shows it's original position (as if the tabBar was still there) before shifting downwards to the correct position.
After searching for some time I found a similar post:
Auto Layout and "Hide bottom bar when pushed"
Unfortunately the solution of selecting the bottom constraint of the new view to Bottom Layout Guide.Bottom is no longer available in iOS 9 (it is greyed out). I followed several suggestions to set the bottom constraint to the container margin but it did not help this shift downwards.
Has anyone found a solution for this problem? It seems the geometry of hiding the tabBarController is only recognised after the push transition has completed.
It turns out my inputAccessoryView was causing the odd scrolling behaviour. The solution that worked for me was to add view.layoutIfNeeded() just before returning the accessoryView in the override:
override var inputAccessoryView: UIView? {
get {
view.layoutIfNeeded()
return accessoryView
}
So for this special case that involves a navigationController embedded in a tabBarController where you like to push to a viewController that hides the tabBar:
check Hide Bottom Bar on Push on storyboard
pin the bottom of the view you are presenting to the container bottom (use method suggested above or just select the pin icon at the bottom of your screen and on the bottom constraint select the drop down arrow and pin to view)
Then finally if you are using an inputAccessoryView, add layoutIfNeeded() in the override to the getter as I have done above.
In Xcode7 you have to right click your element, draw a line to the bottom until the constraint selector pops up. Constraint selector
Then press ALT and now you'll get the desired Bottom constraint

Add a UIImageView to the back of NavigationBar (NOT background image)

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.

Scrollview scrollsToTop doesn't work when containing multiple side by side tableviews? Have searched repeatedly

I looked in this thread and tried everything I saw, and I can't seem to get it working.
Scroll to top of UITableView by tapping status bar
I have a UINavigationController and a UITabBarController. The application first opens to a UICollectionView.
When the user makes a selection, it brings up a ScrollView run by a custom UIViewController ("ScrollViewController"). The ScrollViewController makes four TableViewControllers and puts their TableViews in the ScrollView side by side with paging enabled, and has a floating UIPageControl as well.
Tapping the top bar scrolls the CollectionView to the top, but once I bring up the ScrollView, I can't scroll up from anywhere. I have tried setting all the TableViews' scrollsToTop to NO, no change.
Any suggestions?
That's correct. You can only have one scroll view controlled by the tap of the status bar. If you have multiple scroll views on the screen (either hidden or visible) you can set one of them to be controlled by the status bar tap by disabling the auto scroll on all of the other scroll views using scrollsToTop = NO, that includes anything that uses a scroll view within it, like a table view or a pager.
self.myTableView.scrollsToTop = NO;
According to Apple's documentation:
On iPhone, the scroll-to-top gesture has no effect if there is more than one scroll view on-screen that has scrollsToTop set to YES.

Resources