Reputation:
Getting error when i call the UIAlertView
:
/Users/sun/Projects/csharp/csharp/ViewController.cs(13,13): Warning CS0618: 'UIAlertView.UIAlertView(string, string, UIAlertViewDelegate, string, params string[])' is obsolete: 'Use overload with a IUIAlertViewDelegate parameter' (CS0618) (csharp)
Code:
void HandleTouchUpInside(object sender, EventArgs ea)
{
new UIAlertView("Touch2", "TouchUpInside handled", null, "OK", null).Show();
}
Upvotes: 2
Views: 763
Reputation: 74144
The warning and error are two different things.
Error:
The invalid selector on the TouchUpInside
can be caused be a few different things, since you did not post code on how you are setting it up, but I would look at if you have any additional actions for the button assigned in the Storyboard, if the button (or its ViewController) is going out of scope, etc..
Warning:
Warning CS0618: 'UIAlertView.UIAlertView(string, string, UIAlertViewDelegate, string, params string[])' is obsolete:
UIAlertView is deprecated in iOS 8, so if you are targeting iOS 9+, you should use UIAlertController
var uiAlert = UIAlertController.Create("Touch2", "TouchUpInside handled", UIAlertControllerStyle.Alert);
uiAlert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (alertAction) => {
alertAction.Dispose();
uiAlert.Dispose();
}));
await PresentViewControllerAsync(uiAlert, true);
Upvotes: 1