uiview and uiscrollview - iphone

i am creating a dropdown button in my app. Like a pop-up control which is available in webapps. so when i click on a button, a new UIView containing a UIPickerView appears. i user beginanimations and commitanimations for dispalying and hiding the UIView. the new uiview is half the size of the scrollview.
I want that whenever the new uiview appears, the size of the scrollview should alter so that the i can scroll through the entire view. something like, when a keyboard appears, we reassign the size of scrollview, so that we can scroll entire view.
So how will i know, when the uiview appears. Is there a notification for beginanimations and commitanimations like for keyboard (UIKeyboardDidHideNotification)
thnx in advance.

if the subview you create and show have a viewController, -(void)viewWillAppear method of the viewController will be called on every appearance of that view.
In that method, you can somehow get the superview (for example calling nextResponder method) and resize the superview according to your needs.
Hope that helps.

Related

UITableView Scroll w/ keyboardWillShow

I have uitableview scrolling upwards when keyboardWillShow event occurs. tableview is 320x148 and placed at the bottom of the uiview. When a user selects the first uitextfield, nsnotifcation is fired and moves the textfield accordingly.
My problem is, I have a label and logo in the background (uiview) that i want to see move upwards with the "event". I can do this with an animation, but it's not the desired effect.
My guess is to somehow make uiview move with uitableview somehow. Hope that makes sense.
Humm, i think you could put your UITableView inside a UIScrollView. When the UITableView scrolls, you could do the same to the UIScrollView behind..

View elements resize problem

I have a UiView which contains a UiWebview, UIButton and a UITextView as its elements.
I add this UiView to a UIScrollView and resize the frame so that the text view is not visible. When i click the button i resize the view to display the entire UIView including the UItextview.
The problem is , the text view appears below the view when i resize the frame. When i click expand it covers the text view too.
When view is first added i want the view to display just the webview and the button and when button is pressed it should display the text view.
How do i achieve it? Has it got to do with view hierachy?
you should enable clipping on the UIView .
edit:
I wouldn't resize the view. Instead I would just change the hidden-property on the textview. If you want to add some animations later then you can modify the alpha-property as well.

Prevent subview from scrolling in a UIScrollView

I have a UIScrollView subclass with a certain subview I'd like to prevent from scrolling (while all the other subviews scroll as normal).
The closest example to this I can think of is UITableView's "index strip" on the right side (look in the Contacts app to see an example). I am guessing this is a subview of the table (scrollview) but it does not move as the user scrolls.
I can't seem to make my subview stay put! How can I accomplish this?
The trick is to adjust the frame of the "non-scrollable" subview inside -layoutSubviews.
Add the view that you want not to move as a sibling view of the scroll view on top of the scroll view instead of as a subview.
You can set it's property called userInteractionEnabled to NO

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.