2
votes

I have a ScrollView which shows photos. When touching the screen, a UIToolBar pops up, with several UIBarButtonItem buttons, like Previous, Next, Play... If the users doesn't do anything for 5 seconds, the toolbar disappears again.

It's all very similar to the Apple Photos app.

Everything works as it should, but there's one thing I'm struggling with: I cannot get touches for if the user pressed the buttons, nor can I check on the highlight status of the button.

So there's a problem if the user keeps a button pressed for a few seconds... the program will assume nothing has happened, and remove the toolbar after the 5 seconds have passed.

The Photos app does not have this problem. Even better: when you keep the Next or Previous button pressed or longer than a second, it already executes the "action" associated with the UIBarButtonItem !

In short, I want to do one of these: - to know whether a UIBarButtonItem is pressed - to know whether a UIBarButtonItem is highlighted - or else just know whether there's any press anywhere going on

1
sounds like your IB connection is not setuser207616

1 Answers

2
votes

You could try attaching a custom subclass of UIGestureRecognizer, which tells you when the users interacts with the view to the toolbar.

Alternatively, you could try subclassing UIToolbar and change its -[touchesBegan:withEvent:] and -[touchesEnded:withEvent:] methods to tell you when the users starts/stops interacting with anything on the toolbar.

The latter is probably simpler.