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
According to foreign media reports, the BepiColom...
1. First you need to digest the information about...
On December 8, a short video blogger recently rel...
What is the price of renting an online server for...
Tmall Double Eleven 2017 is coming soon. During t...
In the ending of "In the Name of Family"...
Introduction Users' following, comments, unfo...
In 1948, the first cartoon orange cat was born on...
User portraits are a way of describing and depict...
【51CTO.com Quick Translation】Would you like to qu...
Albert: Learn English without taking detours Reso...
The last release of the Honor Magic series was at...
"The mole on your palm, I always remember wh...
The list of "scientific" rumors for Dec...
On November 5, at the press conference of the Joi...