简体   繁体   中英

Resign UIScrollView as a first responder

I add a custom view to my UIScrollView How can I make my UIScrollView, respond to scroll events Also, there are a few buttons in my customView with should respond on "touch up inside"

entry526 = [[_526 alloc] initWithNibName:@"0526" bundle:nil];
        entry526.view.frame = entry526.view.bounds;
        [self.scrollView addSubview:entry526.view];
        self.scrollView.contentSize = entry526.view.frame.size;
        entry526 = nil;

UPD: I have managed to make my ScrollView scroll, but buttons still do not respond. This is how they are presented:

UIScrollView
  -UIView
    -UIButton

在此处输入图片说明

To make your scroll view respond to scroll events, you need to set the contentSize property to something larger than the frame of the UIScrollView.

To make your buttons respond to touch up inside, do it like you always would. Link them to an IBAction in Interface Builder or call the addTarget on the button in code.

There are a million examples of both these questions on SO and the web.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM