IOS8 after Uialertview and uiactionsheet two alert pages will be created by Uialertcontroller
Source: Internet
Author: User
<span id="Label3"></p><p class="p1"><p class="p1"><span class="s1"><strong>1.</strong></span></p></p><p class="p1"><p class="p1"><span class="s1"><strong>Important:</strong> <span class="s2">Uialertview is<span class="s1"> deprecated in IOS 8. (Note that <span class="s2">uialertviewdelegate is<span class="s1"> also deprecated.) To create and manage alerts in IOS 8 and later, instead use <span class="s3">uialertcontroller</span> with a <span class="s3">preferredstyle</span> of C10>uialertcontrollerstylealert. </span></span></span></span></span></p></p><p class="p2"><p class="p2"><span class="s4">Uialertview and <span class="s1">Uialertviewdelegate (proxies are given block callbacks, simpler) <span class="s4">are deprecated in iOS8 and later versions, instead using style as <span class="s3"> Uialertcontrollerstylealert</span> 's <span class="s3">uialertcontroller</span> to Replace. </span></span></span></p></p><p class="p1"><p class="p1"><span class="s1"><strong>2.</strong></span></p></p><p class="p1"><p class="p1"><span class="s1">In apps this run in versions of iOS prior to iOS 8 with the <span class="s2">Uialertview<span class="s1"> 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 <span class="s3">Uiactionsheet</span>). </span></span></span></p></p><p class="p3"><p class="p3"><span class="s1">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.</span></p></p><p class="p1"><p class="p1"><span class="s1"><strong>3.</strong></span></p></p><p class="p3"><p class="p3"><span class="s1">How do I create a uialertview version of IOS 8 earlier?</span></p></p><p class="p5"><p class="p5"><span class="s1">-(instancetype) initwithtitle: (<span class="s3">nsstring</span> *)<em>title<br></em>Message: (<span class="s3">nsstring</span> *)<em>Message<br></em>Delegate: (id)<em>Delegate<br></em>Cancelbuttontitle: (<span class="s3">nsstring</span> *)<em>cancelbuttontitle<br></em>Otherbuttontitles: (<span class="s3">nsstring</span> *)<em>otherbuttontitles,<br></em>, <em>...</em></span></p></p><p class="p1"><p class="p1"><span class="s1"><strong>4.</strong></span></p></p><p class="p3"><p class="p3"><span class="s1">How do IOS 8 and later build uialertview?</span></p></p> <ol class="ol1"> <ol class="ol1"> <li class="li5"><span class="s1">uialertcontroller* alert = [uialertcontroller alertcontrollerwithtitle:@ "My alert"</span></li> <li class="li1"><span class="s5"><span class="s2">message:@ "this was an alert." <span class="s1">preferredstyle:uialertcontrollerstylealert];</span></span></span></li> <li class="li1"></li> <li class="li5"><span class="s1">uialertaction* defaultaction = [uialertaction actionwithtitle:@ "ok" style:uialertactionstyledefault <span class="s4">handler:^ ( Uialertaction * Action) {}];</span></span></li> <li class="li1"></li> <li class="li5"><span class="s1">[alert addaction:defaultaction];</span></li> <li class="li5"></li> <li class="li5"><span class="s1">[self Presentviewcontroller:alert Animated:yes completion:nil];</span></li> </ol> </ol><p class="p1"><p class="p1"><span class="s1"><strong>5.</strong></span></p></p><p class="p4"><p class="p4"><span class="s1"></span> <span style="line-height: 1.5;">How do I create a uiactionsheet version of IOS 8 earlier?</span></p></p><p class="p1"><p class="p1"><span class="s1">-(instancetype) initwithtitle: (<span class="s6">nsstring</span> *)<span class="s2"><em>title</em></span></span></p></p><p class="p1"><p class="p1"><span class="s1">Delegate: (id<<span class="s6">uiactionsheetdelegate</span>>)<span class="s2"><em>Delegate</em></span></span></p></p><p class="p1"><p class="p1"><span class="s1">Cancelbuttontitle: (<span class="s6">nsstring</span> *)<span class="s2"><em>cancelbuttontitle</em></span></span></p></p><p class="p1"><p class="p1"><span class="s1">Destructivebuttontitle: (<span class="s6">nsstring</span> *)<span class="s2"><em>destructivebuttontitle</em></span></span></p></p><p class="p1"><p class="p1"><span class="s1">Otherbuttontitles: (<span class="s6">nsstring</span> *)<span class="s2"><em>otherbuttontitles</em></span></span></p></p><p class="p5"><p class="p5"><span class="s4">, <span class="s1"><em>...</em></span></span></p></p><p class="p1"><p class="p1"><span class="s1">6.</span></p></p><p class="p3"><p class="p3"><span class="s1">How do IOS 8 and later build uiactionsheet?</span></p></p><p class="p1"><p class="p1"><span class="s7"><span class="s1">Uialertcontroller *ALERTVC = [uialertcontroller alertcontrollerwithtitle:@ "cang teacher hello" message:@ "i heard your new movie was downloaded 9,999 times" preferredstyle:uialertcontrollerstylealert];</span></span></p></p><p class="p1"><p class="p1"><span class="s1"></span></p></p><p class="p1"><p class="p1"><span class="s1">Uialertaction *action1 = [uialertaction actionwithtitle:@ "ok" style:uialertactionstyledefault handler:^ ( Uialertaction * _nonnull Action) {</span></p></p><p class="p1"><p class="p1"><span class="s1">Self.lblTarget.text = [nsstring stringwithformat:@ "click The Alertview OK button to generate a random number"];</span></p></p><p class="p1"><p class="p1"><span class="s1">Self.lblTarget.textColor = [uicolor redcolor];</span></p></p><p class="p1"><p class="p1"><span class="s1">}]; Click the button after the block callback to execute this method, so no need to use the agent</span></p></p><p class="p1"><p class="p1"><span class="s1"></span></p></p><p class="p1"><p class="p1"><span class="s1">Uialertaction *action2 = [uialertaction actionwithtitle:@ "cancel" style:uialertactionstylecancel handler:^ (UIAlertAction * _nonnull Action) {</span></p></p><p class="p1"><p class="p1"><span class="s1">}]; /*uialertactionstylecancel Blue font, bold;</span></p></p><p class="p1"><p class="p1"><span class="s1">Uialertactionstyledefault Font blue, not bold;</span></p></p><p class="p1"><p class="p1"><span class="s1">uialertactionstyledestructive Font red, not bold;</span></p></p><p class="p1"><p class="p1"><span class="s1">*/</span></p></p><p class="p1"><p class="p1"><span class="s1">[ALERTVC addaction:action1];</span></p></p><p class="p1"><p class="p1"><span class="s1">[ALERTVC addaction:action2];</span></p></p><p class="p1"><p class="p1"><span class="s1">[self PRESENTVIEWCONTROLLER:ALERTVC animated:yes completion:nil];</span></p></p><p><p>IOS8 after Uialertview and uiactionsheet two alert pages will be created by Uialertcontroller</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service