cell
cell

Reputation: 119

IOS: UIButton from UISwipeGestureRecognizer

I want to assign a result of swiping to a button, so I can proceed with further actions. I found a straightforward way of doing it, but unfortunately not very elegant and throwing a warning.

Example: assume recognizer is an instance of UISwipeGestureRecognizer. Then...

UIButton *buttonHit = [recognizer view];

It works, but results in

Incompatible pointer types initializing 'UIButton *' with an expression of type 'UIView *'

Any better way of achieving the same? I didn't find any UIButton special constructor. I must be missing something simple. Thanks a lot.

Upvotes: 0

Views: 211

Answers (1)

George
George

Reputation: 1465

UIButton * buttonHit = (UIButton *)[recognizer view];
NSAssert([buttonHit isKindOfClass:[UIButton class]], @"Recognizer must be associated with a UIButton");

Upvotes: 1

Related Questions