c# - Xamarin 警报失败
<p><p>调用 <code>UIAlertView</code> 时出错:</p>
<pre><code>/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></pre>
<p> <a href="/image/G9ML4.png" rel="noreferrer noopener nofollow"><img src="/image/G9ML4.png" alt="enter image description here"/></a> </p>
<p>代码:</p>
<pre><code> void HandleTouchUpInside(object sender, EventArgs ea)
{
new UIAlertView("Touch2", "TouchUpInside handled", null, "OK", null).Show();
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>警告和错误是两个不同的东西。</p>
<p>错误:</p>
<p><code>TouchUpInside</code> 上的无效选择器可能是由一些不同的原因造成的,因为您没有发布有关如何设置它的代码,但我会看看您是否有任何其他操作对于 Storyboard 中分配的按钮,如果按钮(或其 ViewController)超出范围等。</p>
<p>警告:</p>
<blockquote>
<p>Warning CS0618: 'UIAlertView.UIAlertView(string, string, UIAlertViewDelegate, string, params string[])' is obsolete: </p>
</blockquote>
<p>UIAlertView 在 iOS 8 中已弃用,因此如果您的目标是 iOS 9+,则应使用 UIAlertController</p>
<pre><code>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);
</code></pre></p>
<p style="font-size: 20px;">关于c# - Xamarin 警报失败,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/48051799/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/48051799/
</a>
</p>
页:
[1]