Overlapping views in Storyboard - ios

I am trying to design two UIViews in storyboard which overlap and are part of same UIviewController. Only one of them is visible at a time so I set alpha to be 0 or 1 in the code depending upon which one I need to show. The problem is I need to layout these views in Storyboard, and the moment I put the second view, the first view in Storyboard does not responds to mouse clicks, even if I set alpha of second view to 0 in the Storyboard. Is there a way to design both the views and modify them anytime at will easily?

You can explore you view controller's view hierarchy (and select any view you want) with the sidebar
If you don't see the sidebar, tap on the button to expand it

Related

UIButtons not working in Scroll View

I have a Scroll View with a View (content view) inside of it. I've added two buttons to test. The Scroll View scrolls fine but the buttons within the content view are not clickable. I've seen plenty of posts saying this issue happens when they programmatically add UIButtons to the View, but I am not doing this. Here is my exact process:
Drag the Scroll View onto the main view. Add 4 constraints
Drag the Content View onto the Scroll View. Add 4 constraints.
Add 2 Buttons (one high and one low to test scrolling) to the Content View.
This is all I am doing, no code at this point. Is there anything else I have to do to allow the buttons to be clicked? Here is a screenshot of my xib:
Update:
When hooking the button up to a simple IBAction and logging a message, it turns out it IS being pushed and working properly. However, when the button is pushed, the button isn't changing colors like it should (its "pressed" state is not appearing). Any ideas why?
First make the button to custom type
Select button from storyboard then on right attributed inspector change its "state config" to whatever you need like Highlighted, selected, Disabled and default and choose the colour for each state.
Now you can see the colour change on that button.
A UIScrollView first needs to know whether or not you are going to scroll before letting the touch pass to its child views. If you want the child views to get the touch immediately, set the UIScrollView's delaysContentTouches to NO.

UICollectionViewCells in second column are not responding

In my application, I have used UICollectionView:
Inside the collection view cell, I have a view button.
If we click on that button, another view will be opened displaying the details of the graph and an enlarged image.
The problem is that if I click on the view button in the cells present of left column i.e. first column everything is working properly, but if I click on the view button in the right side column or 2nd column cells, the detail view does not appear and they become unresponsive.
I do not understand the problem. It is working well for left side cells, then why is it not working for right side cells?
Check your view dimensions and make sure that collection view is not overlapped with other views, it seem that it is not recognisisng the ui gestures at those points..
I got the problem, the problem is i am adding the collection view to a subview named display view and then adding to the parent view, but the main screen frame width is less than the collectionview so the uievents are not recognised at that column part, so i have deleted that display view and added the collection view directly to the parent view and now it is working..

iOS iPhone mapview with slide-up scrollview - How to set up?

I am struggling with how to set up the following view arrangement. Not sure what viewcontrollers I should use. Should I use a container view (I'm only supporting iOS6+)?
I have a screen that contains a mapview (and view controller) that is working great. I want to add a view to this screen that slides up from the bottom to partially cover the mapview. This subview will be a scrollview and will have a small handle that is visible even when closed that a user can drag up to open or down to close. When this drawer view is open, the user can "page" left and right through a list of objects and the map will update accordingly.
I don't need any help with the map view or scroll view individually, only how the generate this screen with the multiple views.
Everything I have done thus far is via Interface Builder.
Thanks!
You could create a empty xib (UIViewController) and add this Xib file as subview of the main view. Next add a gesture recognizer to the main view (https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizer_basics/GestureRecognizer_basics.html), on the right gesture slide the subview up (http://www.raywenderlich.com/2454/uiview-tutorial-for-ios-how-to-use-uiview-animation).

Best time in View lifecycle to determine the on-screen size of a UIScrollView

I have a .xib containing a view which itself containing top and bottom accessory views (navigation, a page control) and a UIScrollView. Its height varies depending on whether I'm running on an iPhone 4 or 5 (3.5" or 4"). At runtime I move the containing view offscreen, populate the scrollview with UIButtons to build a scrollable launchpad, and scroll this on to the screen from the bottom. Tapping a button shows another view.
On a smaller screen I'd like to show only three buttons in the scrollview, on the larger one I show four. So I need to know the height that the scrollview will be when it appears, before it actually appears. I'd hoped to have this information available at some point in the view lifecycle (viewWillAppear etc.) but the only place this seems to be correct is in viewDidAppear. At this point the view is already on screen and creating the buttons then means they appear suddenly, and are not scrolled nicely onscreen.
The top-level view in the .xib is set to Retina 4 FullScreen.
I'm happy to concede that viewWillAppear is the correct place to create the buttons and my navigation controller is perhaps instantiating the view incorrectly, but my iOS-fu isn't strong enough to say for certain.
My solution has been to detect screen size and hardwire the button height. Is there a better (more elegant, future-proof and canonical) way to do this?
Don't worry, you are in the right direction:
viewWillAppear is the correct method in a view's lifecycle, where the frames of that view and its subviews are completely calculated and nothing has been drawn yet. Here you can make corrections to the standard behavior of your view.
When viewDidAppear gets called, you get the same information about positions and sizes of view elements as in viewWillAppear. But at this time, the animations and the view itself already have been drawn.
That is, why you'll want to use viewWillApear.

Embedding a UIContainerView as a portion of screen in a UIViewController

I have a screen in my storyboard where I would like to embed a container view into a portion of the screen. I can't figure out if I should add a new containerview or view from the object library and then drag in a collection view controller or collection view (or tackle it a different way?). I've tried all combinations but just end up with the embedded view being shown black even if I drag collection view cells and set a background colour to test it. Once I can get this working I plan to populate the cells from an external database.
Any suggestions please? I'm doing this using storyboard as far as possible.
Thank you.
After you drag a container view into your view, you automatically get an embedded view controller, whose size is matched to the container view's size. You should delete that controller, and drag in a UICollectionViewController. Control drag from the container view to this controller and choose embed when you let go -- this will resize the collection view controller. You can give the collection view a background color, so you will see where it is, but giving the cells a background color won't show up until you implement the methods in the controller to populate those cells.

Resources