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
Nanjing tea drinking and takeaway private studio ...
The story of radio and television is always long,...
To do a good job in user operation , the first st...
"I'm in the United States, just got off ...
If you have questions about the coronavirus Espec...
At the Google I/O Developer Conference in May thi...
All Chinese citizens, as long as their family'...
After nearly two years of rapid development, the ...
A gold medal represents the highest honor in the ...
The chaos and reasons under the Internet thinking...
The Tibetan fox , with its confused and world-wea...
In the past ten years, the televisions sitting in...
Preface In the Android technology circle this yea...
Recently, a new exercise craze is emerging. After...