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
This article was reviewed by Pa Li Ze, chief phys...
In Fuzhou, Fujian, dancer Xiaowen worked for near...
Through the exaggerated expression of Murphy'...
Say Goodbye to Singleness: When Love Knocks on th...
It is hard to imagine that such tempting keywords...
How crazy are Lu Han’s fans? Douban user Vivian d...
[[383293]] Today's front-end development is b...
A few days ago, the news that a certain celebrity...
Apple has been in a lot of trouble recently. It s...
As one of the windows for displaying individuals ...
When you are bored, irritable, or have a hard tim...
[51CTO.com original article] For many Internet bu...
Android 5.0 was just launched not long ago, and n...
Except for the theatrical version of Detective Co...
Every sentence he said was about being far ahead....