1.
Important: Uialertview is deprecated in IOS 8. (Note that uialertviewdelegate is also deprecated.) To create and manage alerts in IOS 8 and later, instead use Uialertcontroller with a preferredstyle of C10>uialertcontrollerstylealert.
Uialertview and uialertviewdelegate (proxies are given block callbacks, simpler) are deprecated in iOS8 and later versions, instead using style as Uialertcontrollerstylealert 's uialertcontroller to replace.
2.
In apps this run in versions of iOS prior to iOS 8 with the Uialertview class to display a alert message to the U Ser. An alert view functions similar to but differs in appearance from a action sheet (an instance of Uiactionsheet).
IOS8 Previous versions of Uialertview and Uiactionsheet have similar functionality, but are generated by different classes. Overtones, iOS8 later versions, Uialertview and Uiactionsheet two alert pages will be generated by Uialertcontroller.
3.
How do I create a uialertview version of IOS 8 earlier?
Objective-c
-(Instancetype) Initwithtitle: (nsstring *)title
Message: (nsstring *)message
Delegate: (ID)delegate
Cancelbuttontitle: (nsstring *)Cancelbuttontitle
Otherbuttontitles: (nsstring *)otherbuttontitles,
, ...
4.
How do IOS 8 and later build Uialertview?
- uialertcontroller* alert = [Uialertcontroller alertcontrollerwithtitle:@ "My alert"
- message:@ "This was an alert." Preferredstyle:uialertcontrollerstylealert];
- uialertaction* DefaultAction = [uialertaction actionwithtitle:@ "OK" Style:uialertactionstyledefault handler:^ ( Uialertaction * action) {}];
- [Alert addaction:defaultaction];
- [Self Presentviewcontroller:alert animated:yes completion:nil];
5.
How do I create a uiactionsheet version of IOS 8 earlier?
-(Instancetype) Initwithtitle: (nsstring *)title
Delegate: (id<uiactionsheetdelegate>)delegate
Cancelbuttontitle: (nsstring *)cancelbuttontitle
Destructivebuttontitle: (nsstring *)destructivebuttontitle
Otherbuttontitles: (nsstring *)otherbuttontitles
, ...
6.
How do IOS 8 and later build Uiactionsheet?
Uialertcontroller *ALERTVC = [Uialertcontroller alertcontrollerwithtitle:@ "Cang teacher Hello" message:@ "I heard your new movie was downloaded 9,999 times" Preferredstyle:uialertcontrollerstylealert];
Uialertaction *action1 = [uialertaction actionwithtitle:@ "OK" Style:uialertactionstyledefault handler:^ ( Uialertaction * _nonnull action) {
Self.lblTarget.text = [NSString stringwithformat:@ "Click the alertview OK button to generate a random number"];
Self.lblTarget.textColor = [Uicolor Redcolor];
}]; Click the button after the block callback to execute this method, so no need to use the agent
Uialertaction *action2 = [uialertaction actionwithtitle:@ "Cancel" Style:uialertactionstylecancel handler:^ (UIAlertAction * _nonnull action) {
}]; /*uialertactionstylecancel blue font, bold;
Uialertactionstyledefault font blue, not bold;
uialertactionstyledestructive font red, not bold;
*/
[ALERTVC Addaction:action1];
[ALERTVC Addaction:action2];
[Self PRESENTVIEWCONTROLLER:ALERTVC animated:yes completion:nil];
How do IOS 8 and later build Uialertview?