xCode 4.2 iOS5 interfaceBuilder cannot tap on a button that is laid out in the IB - iphone

I've ran into a weird issue lately:
I have a 320 x640 UIView within a UIScrollView. I've manually positioned buttons throughout the view and assigned actions to them. One of the buttons has a center at [x,y]: [287,440]. The button is 60x60.
I can tap all other buttons and controls located as low as Y = 353.
I see that the button is located on the same level as all of my other buttons, within the same view as them.
What could be causing my button to be completely untappable? I have another controller, which is also "tall", and there buttons located "off screen" are tappable. [If I move the button up to the level of other buttons, it works as expected.]
Here's the scroll view code:
self.scrollView.contentSize=CGSizeMake(320, 640);

Something is covering it. Try looping over all subviews and printing origin.y relative to scrollview origin.y, and then height plus relative position. Do this in viewWillAppear. Be aware that autoresizing behavior can kick in right after viewDidLoad and fool you. That is what happened to me earlier. There will be an overlap somewhere.
Can post code example later from home if this doesn't get you through it.

Related

Adding UIButton to UIImageView within UIScrollView on Swift

I am writing an application for an event my organization is hosting using Swift. I have an image with the floor layout and want to add buttons to select locations (such as bathrooms, entrances, exits, emergency sections, etc) so that people can click them and information about the location pops up.
I currently have an imageview with the floor layout within a scrollview to allow the user to zoom in and out of the image. When I try to add buttons to the scrollview they don't stay relative to the image when zooming in and out, nor do their size change. I have tried adding constraints on to make the location stay the same when zooming in and out.
It also won't let me relocate the button on the storyboard to be a subview of the imageview. Looking up similar solutions says to add the button programmatically as a subview of the imageview but then it'd be really hard to put the 100+ buttons in the right location. Any suggestions as to how to go about this?
you have no other choice instead of adding by code.. because from code you can add as subview of image view , whereas Storyboard wont add buttons as subviews of imageView, but it will add buttons as subview of Scroll View

How to put my 2 existing buttons to the foreground, they are now behind an imageview

The question is in the title.
There must be a simpel way to do this I guess?
There is an imageview on the screen, there doesn't have to be any interaction with it.
On the imageview I want 2 small buttons left and right but the buttons were created (and the code is written) before the imageview. How do I set this imageview to the background? :)
[self.view sendSubviewToBack:yourImageView];
You can add buttons as subview of imageview.
you can write below code for that:
[imageView addSubview:button1];
[imageView addSubview:button2];
So buttons will be appear in foreground.
When looking at your xib or stoyboard (where you can see the layout), you can use the View Controller scene which is a list of all of the objects, views etc on your Apps layout.
You can click and drag the UI image view so its above the buttons in the list. I'm guessing it's just defaulted to being on top of the buttons.
In your storyboard, choose your viewController by clicking on it. On left side you can see hierarchy like left side view in this image. Check if your imageView is below, in hierarchy, to your 2 buttons. If it is, then drag the imageView and move it above both the buttons.
Concept : The view that is below in hierarchy is visible on top of all the views above it.

floating button above UIScrollView in Storyboard

Is there an easy way of putting a 'floating' button above a UIScrollView in Storyboard? I would like to add a lock button to toggle scrolling on and off. I guess I could do this in code but it would be nice if it could also be done via XCode.
Just drag the button onto the view somewhere over your UIScrollView. Now, IB will automatically dump it in the scroll view, but you can move it out by using the object browser.
Open the object browser
Drag the button out to the same level as the UIScrollView
Ensure that the button is below the scroll view in the list (this means it's above the object in the view hierarchy)
You may have to use the inspector to set the button's actual location rather than dragging it around. Dragging it around for placement will most likely cause it to jump back into the scroll view.

iPhone UIButton Parent Frame Changing Touch Up Inside Event Issue

I have a UIButton within a UIView. The button is docked on the bottom of the view using the Autoresizing Masks. The button is working fine when the view initially loads and the IBAction is being called successfully.
Now when I resize the height of the parent view the button stays docked at the bottom of the view, however now only half of the button responds to the touch events. If I resize the parent view height a bit larger then the button completely doesn't respond anymore.
Any ideas why this would be occurring?
It sounds as if you've got another view, most likely a transparent one, that is resizing improperly and covering up part of the button.
It seems that I was moving the main view as the inner view height was changing. I guess if the UIButton is outside the bounds of the self.view then touches are not received.

iPhone UIScrollview: Button does not respond when located below 480 pixels on Scroll View's child UIView

I have built a view for an iPhone app in Interface Builder. It is a UIScrollview with a UIView and a UIButton on the UIView. The only code I have is setting the scroll view's contentSize to 320x550 in the viewDidLoad method of the xib's File Owner class. When the button is within the normal view area (320x480) the button responds as normal, but if is placed outside of those boundaries in Interface Builder the button will not respond when I scroll to it and click the button.
What am I missing? I figure it might be something I need to set on the UIView. But I am not sure what that is.
Your UIButton won't response even it's visible because it's not in the boundary of parent view. You can see object outside the boundary of its parent view because it's a default behavior of UIView to draw all subview (clipsToBounds = NO)
To see the truth, try this code.
UIView *yourUIView = ...
yourUIView.clipsToBounds = YES;
yourUIView.backgroundColor = [UIColor cyanColor];
You will no longer see your UIButton.
To fix this, enlarge your UIView.
I had the same problem as the person who posted the question. Thanks to the first answer, I had a hint as to what to do. I increased the height of the view by adjusting the frame. This, apparently must be done in code. Once this was done, however, the toolbar at the bottom was no longer visible. So before I adjust the height of the view, I grab the position of the tool bar. Then after adjusting the height of the view, I reset the position of the tool bar. Now all is good.