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
We often say that while learning to maintain old ...
Careful Apple fans will surely find that Apple tr...
Some time ago, China Mobile announced that the fi...
"What is your methodology for data analysis ...
A biosphere reserve is a protected area establish...
Preface: ButterKnife is a View injection framewor...
On February 27, Spreadtrum Communications announc...
The advantages of WeChat mini program investment ...
After years of dormancy overseas, Jia Yueting fin...
Before talking about the method of “old employees...
Author: Chen Wen Reviewer: Han Hongwei Recently, ...
Recently, the pink muhly grass has entered its be...
Produced by: Science Popularization China Author:...
[[135484]] Earlier this week, iPhone users discov...
As Baidu focuses on promoting Baidu APP, it means...