开发者

Why did UIAlertView dismissAnimated: work at all?

I was just trying to dismiss a UIAlertView using the fo开发者_Python百科llowing call:

[serverConnectionClosedAlertView dismissAnimated:YES];

I did some testing and everything worked nicely. When I got back to the Xcode window I saw the warning, "UIAlertView may not respond to '-dismissAnimated'. I looked up the documentation and noticed that this method is indeed not defined on UIAlertView or even UIView. The correct call should have been

[serverConnectionClosedAlertView dismissWithClickedButtonIndex:0 animated:YES];

So, I am wondering

  1. Why did Xcode suggest the original method name (I had pressed ESC to get the list of suggestions and just picked the method above; old Eclipse/Java habit, I guess), and

  2. Why did the code work at all? It actually did dismiss the UIAlertView without any crashes or log entries.


It was in fact called dismissAnimated: in previous versions of the SDK. It has since either been deprecated or made a private API in favor of dismissWithClickedButtonIndex:animated:, but it'll still work if you call it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜