I have an scrollview with some buttons on it. When one button is clicked I want it to be on top of the screen so that the button.frame.origin.y is the self.view.frame.origin.y. How do I do this?
You can do this
- (void)buttonPressed:(UIButton*)sender
{
[scrollView setContentOffset:sender.frame.origin animated:YES];
}
Use the - (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated
method.
To scroll the view to the desired frame when the button is pressed.
For example:
- (void)buttonPressed:(UIButton*)sender
{
[scrollView scrollRectToVisible:desireFrameFromButton];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.