Use native iOS events in Xamarin.iOS
To access target events, in iOS you usally use this:
[self addTarget:self action:@selector(wasPressed) forControlEvents:UIControlEventTouchDown];
Xamarin provide much smarter syntax for event wire up, because c# has much nicier EventHandlers. Here is an example:
AddTarget(OnTouchDown, UIControlEvent.TouchDown);
And OnTouchDown is this method:
private void OnTouchDown(object sender, EventArgs e)
{
// do your on-touch-down logic here, for example - change view's background color
}
Written by Олег Гаврилов
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Event
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#