UIButton touch is delayed when in UIScrollView

前端 未结 7 1555
遥遥无期
遥遥无期 2020-11-30 19:01

I\'m running into a small issue in my app.

I essentially have a series of UIButtons added as subviews in a UIScrollView which is part of a

7条回答
  •  一个人的身影
    2020-11-30 19:28

    None of the existing solutions worked for me. Maybe my situation is more unique.

    I have many UIButtons within a UIScrollView. When a UIButton is pressed a new UIViewController is presented to the user. If a button is pressed and held long enough, the button will show its depressed state. My client was complaining that if you tap too quickly, no depressed state is shown.

    My solution: Inside the UIButtons' tap method, where I load the new UIViewController and present it on screen, I use

    [self performSelector:@selector(loadNextScreenWithOptions:) 
               withObject:options 
               afterDelay:0.]
    

    This schedules the loading of the next UIViewController on the next event loop. Allowing time for the UIButton to redraw. The UIButton now shows its depressed state before loading the next UIViewController.

提交回复
热议问题