views:

264

answers:

3

I've been trying different things the last few days and I've run out of ideas so I'm looking for help. The situation is that I'm displaying my in-app purchasing store view after the user clicks a button. Button pressed, view is displayed. The store shows fine. Inside this view, I have a few labels with descriptions of the product, and then below them I have the price and a Buy button which triggers the in-app purchase. Problem is when I rotate the phone to landscape, that Buy button no longer responds, weird. Works fine in portrait.

The behavior in landscape when the I touch the button is nothing. It doesn't appear to press down and be selected or anything, just not responding to my touches. But then when I rotate back to portrait or even upside down portrait, it works fine.

Here is the rough structure of my view in IB, all the rotating and layout is setup in IB. I set the autoresizing in IB so that everything looks ok in landscape and the Buy button expands horizontally a little bit. The only layout manipulation I do in my code is after loading, I set the content size of the scroll view.

File Owner with view set to the scrollView      
/ scrollView  
----/ view  
--------/ label  
--------/ label  
--------/ label  
--------/ label  
--------/ label  
--------/ label  
--------/ label  
--------/ label  
--------/ uibutton (Buy)  

After orientation changes I printed out the userInteractionEnabled property of the scrollView and the button, and they were both TRUE at all orientations.

Ideas? Or maybe some other way of displaying a buy button that won't be nonfunctional? I've already begun a branch that plays with a toolbar and placing the buy button there, but I can't seem to get the bar to stay in place while scrolling.

A: 

Mmmm, maybe the button is within a UIView that not rotates as device do, then you view your button as always but out of the view container that propagates the touches.

You can check, in IB, the anchor of the view within its containers or do coding.

Espuz
If the view has a bgcolor and I can see the color behind the button, does that mean the button is within the bounds of the view? That's what I see. So if I can assume the button is within the view, what other reasons could cause touches not being passed down? In landscape, the button does drop down below the screen, which I get to by scrolling. Could the scrollview have anything to do with it?
casey
Yes, if you see the bgcolor then the button is into the view. I don't know what can be the problem, maybe the scroller issue. Sorry.
Espuz
A: 

Since I couldn't get that UIButton to work correctly, I ended up just scrapping the button and creating a new parent view containing everything I currently have and then adding a toolbar below it and placing a button on there. This problem really didn't seem like it warranted this much of my time which is why I just went a different way.

File Owner with view set to the parent view  
/ view
----/ scrollView  
--------/ view  
------------/ label  
------------/ label  
------------/ label  
------------/ label  
------------/ label  
------------/ label  
------------/ label  
------------/ label  
----/ toolBar  
--------/ barbutton (Buy)  
casey
A: 

It sounds like you got around your issue, but just in case others come looking, I ran into a similar issue and found a solution.

I was programmatically adding the scrollview. I would then call setContentSize to make sure the scrollview was as tall as the view I wanted to show. The view I was showing was setup with both UIViewAutoresizingFlexibleWidth and UIViewAutoresizingFlexibleHeight.

When I rotated to Landscape mode while testing, it looked like my subview was all there but I couldn't click on anything when I scrolled down. I think the issue was that since my subview was setup to have a flexible height, it was being shrunk vertically when the scrollview shrunk. Perhaps I was still seeing it as expected because I wasn't clipping or something?

Either way, once I only had my subview have a flexible width, everything works again. You should be able to turn off flexible height programmatically or in interface builder (the arrow in the box pointing up and down).

Will Mavis