I have a UIButton in a ScrollView. This button is hided by the NavigationBar, so it is visible only when the user drag down the ScrollView. I want to check the position of the UIButton, and if the y position is <= 41 then i want to display an Alert
How can I make this?
Thanks!! Bye
The position of the yButton never changes (As in the frame of the yButton is the same in the scroll view). What does change is the contentOffset property of the UIScrollView. So you can implement the delegate method – scrollViewDidScroll: which can implement the logic to determine if the button is in your desired state.
Related
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..
I have a UIScrollView, inside it, a small UIView containing a UIPickerView.
I'm able to scroll the view up and down but whenever I try to scroll the picker, it scrolls the view instead. I can change the picker's value by clicking it but not scrolling.
Any ideas?
EDIT: I just tried scrollView.canCancelContentTouches = NO; but it only works when I first Touch and then Drag, as in the TouchesBegan event. The scrollView still scrolls if I touch-move the Picker as in the TouchesMoved event.
What can I do to give my Picker its natural behavior in a ScrollView?
You've already got canCancelContentTouches set to NO, but try setting delaysContentTouches to NO as well.
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.
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
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.