User Guide page Making instance sharing at initial launch of IOS app

Source: Internet
Author: User
<span id="Label3"></p>User Guide page Making instance sharing at initial launch of IOS app<p><p>Old beginning font: [increase decrease] type: reprint time: 2016-03-09 I want to comment</p></p>This article mainly introduces the first launch of the iOS App User Guide page production instance sharing, which determines whether the program is the first time or version after the first launch is a key point, the need for friends can refer to the next<p><p>The application app usually has a guide page, which can be used as a guide to guide the user, or it can be presented to the user to understand the function of the app. Guide page making simple, generally only need a set of pictures, and then show the picture group can Be. The Display Picture group is commonly used Uiscrollview to display the page, and is controlled by the Uipagecontrol page controller to display the current Page. The Uiscrollview and Uipagecontrol collocation will be more perfect to show the function of the guide Page. Let's look at a concrete example:</p></p><p><p>We use the Nsuserdefaults class to determine whether the program is first started or updated, and the following code is added to the appdelegate.swift:</p></p><span style="text-decoration: underline"><span style="text-decoration: underline">Copy Code</span></span>The code is as Follows:<br>Func application (application:uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject:anyobject]?)- > Bool {<p><p></p></p><p><p>Get the version number of the current app<br>Let infodictionary = Nsbundle.mainbundle (). infodictionary<br>Let currentappversion = infodictionary! ["cfbundleshortversionstring"] as! String</p></p><p><p>Remove the previously saved version number<br>Let Userdefaults = Nsuserdefaults.standarduserdefaults ()<br>Let appversion = Userdefaults.stringforkey ("appversion")</p></p><p><p>Let storyboard = Uistoryboard (name: "Main", bundle:nil)</p></p><p><p>If the appversion for nil is the first boot, if appversion is not equal to currentappversion the description is updated<br>if appversion = = Nil | | appversion! = currentappversion {<br>Save the latest version number<br>Userdefaults.setvalue (currentappversion, forkey: "appversion")</p></p><p><p>Let Guideviewcontroller = Storyboard.instantiateviewcontrollerwithidentifier ("guideviewcontroller") as! Guideviewcontroller<br>Self.window?. Rootviewcontroller = Guideviewcontroller<br>}</p></p><p><p>return True<br>}</p></p><br>In guideviewcontroller, we use Uiscrollview to load our guide page:<br><span style="text-decoration: underline"><span style="text-decoration: underline">Copy Code</span></span>The code is as Follows:<br>Class Guideviewcontroller:uiviewcontroller {<p><p></p></p><p><p>@IBOutlet weak var pagecontrol:uipagecontrol!<br>@IBOutlet weak var startbutton:uibutton!</p></p><p><p>private Var scrollview:uiscrollview!</p></p><p><p>Private Let Numofpages = 3</p></p><p><p>Override Func Viewdidload () {<br>Super.viewdidload ()</p></p><p><p>Let frame = Self.view.bounds</p></p><p><p>ScrollView = Uiscrollview (frame:frame)<br>Scrollview.pagingenabled = True<br>Scrollview.showshorizontalscrollindicator = False<br>Scrollview.showsverticalscrollindicator = False<br>Scrollview.scrollstotop = False<br>Scrollview.bounces = False<br>Scrollview.contentoffset = Cgpointzero<br>Set the contentsize of the ScrollView to 3 times times the screen width (depending on the actual Situation)<br>Scrollview.contentsize = cgsize (width:frame.size.width * cgfloat (numofpages), Height:frame.size.height)</p></p><p><p>Scrollview.delegate = Self</p></p><p><p>For index in 0..<numofpages {<br>Notice the name of the picture here<br>Let ImageView = Uiimageview (image:uiimage (named: "guideimage\ (index + 1)"))<br>Imageview.frame = CGRect (x:frame.size.width * cgfloat (index), y:0, width:frame.size.width, height:frame.size.height)<br>Scrollview.addsubview (imageView)<br>}</p></p><p><p>Self.view.insertSubview (scrollView, Atindex:0)</p></p><p><p>Set the fillet for the Start button<br>StartButton.layer.cornerRadius = 15.0<br>Hide Start button<br>Startbutton.alpha = 0.0<br>}</p></p><p><p>Hide the status bar<br>Override func Prefersstatusbarhidden (), Bool {<br>return True<br>}<br>}</p></p><br>Finally we let Guideviewcontroller follow the uiscrollviewdelegate protocol, here to determine whether to slide to the last one to show the Enter button:<br><span style="text-decoration: underline"><span style="text-decoration: underline">Copy Code</span></span>The code is as Follows:<br>MARK:-uiscrollviewdelegate<br>Extension Guideviewcontroller:uiscrollviewdelegate {<br>Func Scrollviewdidscroll (scrollview:uiscrollview) {<br>Let offset = Scrollview.contentoffset<br>As the slide changes the state of the Pagecontrol<br>Pagecontrol.currentpage = Int (offset.x/view.bounds.width)<p><p></p></p><p><p>Because CurrentPage is starting from 0, so numofpages minus 1.<br>if Pagecontrol.currentpage = = numOfPages-1 {<br>Uiview.animatewithduration (0.5) {<br>Self.startButton.alpha = 1.0<br>}<br>} else {<br>Uiview.animatewithduration (0.2) {<br>Self.startButton.alpha = 0.0<br>}<br>}<br>}<br>}</p></p><br>In the above code, in order to appear natural we have added a little animation to the Enter button:]<p><p></p></p><p><p>The final effect is as Follows:</p></p><p><p></p></p><p class="content-shequ"><p class="content-shequ">If you have questions about this article, please submit to the Exchange community, the vast number of enthusiastic netizens will answer for you!! Click to enter the community</p></p><p><p>User Guide page Making instance sharing at initial launch of IOS app</p></p></span>

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.