In the process of upgrading from iOS8 to iOS9, the way of popping up prompt boxes has changed a lot. In Xcode7 and iOS9.0 SDK, it has been clearly pointed out that it is no longer recommended to use UIAlertView, and only UIAlertController can be used. Let's demonstrate it through code. I click a button and a prompt box pops up. The code example is as follows:
This means that UIAlertView was first deprecated (not recommended) in iOS 9. Let's use UIAlertController. However, when running the program, it is found that the code can still run successfully without crashing. But in actual engineering development, we have such an "unspoken rule": to treat every warning as an error. So in order to follow Apple's trend, we solve this warning and use UIAlertController to solve this problem. The code is as follows:
The effect after the program is run is the same as above. There is another option for the preferredStyle parameter: UIAlertControllerStyleActionSheet. After selecting this enumeration type, the effect is as follows: We can see that this prompt box pops up from the bottom. Isn't it simple? By looking at the code, we can also find that the button response in the prompt box no longer needs the delegate to be implemented. We can directly use addAction to implement the button click in a block, which is very convenient. |
<<: The most practical Android architecture design principles
>>: How should a designer with zero foundation learn front-end
Recently, I saw a few complaints about Douyin in ...
Last night, Alibaba's stock price climbed abo...
The growth of a person needs the blessing of birt...
The jailbreak tool for iOS 11~iOS 14.3 released v...
Today, electric vehicles have become the mainstre...
For those who have experienced the early "fla...
App promotion is constantly innovating, and the e...
The best wine, the secrets in the jar With that m...
Some time ago, WeChat was updated on both Android...
Did you know that salt has many uses? In addition...
The electric rice cooker is a common household co...
I don’t know when it started, but the mobile phon...
Mini programs provide convenience for publicity a...
Produced by: Science Popularization China Author:...
Everyone is familiar with advertisements. There a...