ios_20_ Weibo new Features page

Source: Internet
Author: User

Eventually:




Beyondappdelegate.m

beyondappdelegate.m//20_ Handsome no Weibo////Created by Beyond on 14-8-3.//Copyright (c) 2014 Com.beyond. All rights reserved.//#import "BeyondAppDelegate.h" #import "BeyondViewController.h" #import " NewFeatureViewController.h "#import" OauthViewController.h "#define KVERSIONCODEKEY (NSString *) Kcfbundleversionkey@implementation beyondappdelegate//Application First executed Method-(BOOL) Application: (UIApplication *) application Didfinishlaunchingwithoptions: (nsdictionary *) launchoptions{//1, create window Self.window = [[UIWindow alloc] initWithFrame    : [[UIScreen mainscreen] bounds];    2, set the background color of the window Self.window.backgroundColor = [Uicolor Whitecolor];    3, call the custom method, judge is not the first time to use this version of the app, if it is used for the first time, the window's root controller is set to the Newfeature controller, otherwise the host controller becomes the root controller of the window [self versioncodecheck];    4, make the window visible [Self.window makekeyandvisible]; return YES;} Custom method, judging is not the first time to use this version of the app, if it is used for the first time, the window's root controller is set to the Newfeature controller, otherwise directly let the host controller become the root controller of the window-(void) versioncodecheck{//1, Using user preferences, remove the old version number from the sandbox nsstring *oldversioncode = [[NsuserdefaulTS Standarduserdefaults] Objectforkey:kversioncodekey];     NSString *currentversioncode = [[[NSBundle mainbundle]infodictionary] objectforkey:kversioncodekey];    According to the comparison result of the version number into different controller//[self Stepintoviewcontroller:currentversioncode Oldversion:oldversioncode];    Return #warning block Test-=============== The following, and the method in which it is called, is used only for the block call test if ([Currentversioncode isequaltostring:o    Ldversioncode]) {//if (0) {[Self ENTERBEYONDVC]; } else {//key, and save version number [[Nsuserdefaults Standarduserdefaults]setobject:currentversioncode Forkey:kversionco                Dekey];        Enter the new feature controller Newfeatureviewcontroller *NEWVC = [[Newfeatureviewcontroller alloc]init];            Newvc.startblock = ^ (BOOL isSelected) {log (@ "%d", isSelected);        [Self ENTERBEYONDVC];        };    Self.window.rootViewController = NEWVC; }} #warning block test-(void) enterbeyondvc{//1, if you have oauth authorization, go directly to the host controller, otherwise OAuth authorization controller if (1) {Oauthviewco Ntroller *oautHVC = [[Oauthviewcontroller alloc]init];        Self.window.rootViewController = OAUTHVC;    Return    }//Enter the main controller Beyondviewcontroller *VC =[[beyondviewcontroller Alloc]init]; Self.window.rootViewController = VC;}  -(void) Stepintoviewcontroller: (NSString *) curversion oldversion: (NSString *) oldversion{//Compare old and new version number Uiviewcontroller *rootviewcontroller = nil; #warning test the new feature's View if ([Curversion isequaltostring:oldversion]) {//if (0) {/ /description is not the first run, directly instantiate the host controller, set the host controller as the window's root controller//Enter the main controller (the main interface before the status bar, restore) iOS 7 invalid//[[UIApplication Sharedapplicatio        N] Setstatusbarhidden:no Withanimation:uistatusbaranimationfade];    Rootviewcontroller = [[Beyondviewcontroller alloc]init]; } else {//description is the first run, enter the new feature controller, set the new feature controller as the root controller of the window, and save the version number//Enter the new feature controller (the new feature interface first put the status bar, hidden) iOS 7 invalid//[U        IApplication Sharedapplication].statusbarhidden = YES; [[UIApplication Sharedapplication]setstatusbarhidden:yes Withanimation:uistatuSbaranimationslide];        Rootviewcontroller = [[Newfeatureviewcontroller alloc]init];    Key, and save the version number [[Nsuserdefaults standarduserdefaults]setobject:curversion Forkey:kversioncodekey]; }//Set the root controller of the window for the corresponding controller Self.window.rootViewController = Rootviewcontroller;} @end


NewFeatureViewController.h

  newfeatureviewcontroller.h//  20_ Handsome no Weibo////  Created by Beyond on 14-8-3.//  Copyright (c) 2014 Com.beyond. All rights reserved.//  use only once, version new feature controller, enable #import <UIKit/UIKit.h> @interface When first running this version newfeatureviewcontroller:uiviewcontroller//define a block as a member variable, when you click the Start button, initialize the host controller to become the window's root controller//block with Copy@property ( nonatomic,copy) void (^startblock) (BOOL isshare); @end


Newfeatureviewcontroller.m

newfeatureviewcontroller.m//20_ Handsome no Weibo////Created by Beyond on 14-8-3.//Copyright (c) 2014 Com.beyond. All rights reserved.//is only used once, the version of the new feature controller, when the first run of this version is enabled/* Written in front: When a control is not displayed, check the following three properties: no width and height x y coordinate not correctly added to parent control when a control cannot be clicked  Wait, check the following properties: your userinteraction = no parent control's userinteraction = no control itself has exceeded its controller range Pagecontroller height cannot change, then can be set height of 0, other controls the same 4, center display of standard steps: First set center, then set bounds 5, toggle button picture can be done by toggling the state of the button to complete normal: normal highlighted: Highlight (when the person long Press) disabled: failure (through code control) select Ed: checked (controlled by code) */#import "NewFeatureViewController.h" #define Kpicnum 4#warning viewsize to be changed to Kwinsize#define viewsize sel F.view.bounds.size@interface Newfeatureviewcontroller () <uiscrollviewdelegate>{//page indication Controller UIPageControl *_PAG        Econtrol; Because you need to share the button's selected state in the Click event of the Open button UIButton *_sharebtn;} @end @implementation newfeatureviewcontroller-(BOOL) prefersstatusbarhidden{//NSLog before Loadview (@ "prefers bar h    Idden ");    return YES;    }-(void) loadview{NSLog (@ "Load view"); New features, let ImageviEW becomes the controller view and then adds a layer of scrollview uiimageview *imgview = [[Uiimageview alloc]init] ImageView above;    Set the size of the controller view (i.e. Imgview) to full screen imgview.frame = [UIScreen mainscreen].bounds;    NSLog (@ "%@", Nsstringfromcgrect (Imgview.frame));        Using the method in the classification, if it is iphone5, load the -568h picture imgview.image = [UIImage fullscrennimagenamed:@ "New_feature_background.png"];    Let the controller view can interact with the user imgview.userinteractionenabled = YES; The View Self.view = Imgview that makes the Imgeview a controller directly;}    -(void) viewdidload{[Super Viewdidload];    NSLog (@ "View did load");        1, call the custom method, load Uiscrollview, and bulk add Uiimageview, each imageview a picture [self adduiscrollview]; 2, invoke custom method, load Uipagecontrol [self Adduipagecontrol];} Custom methods, load Uiscrollview, and bulk add Uiimageview, one picture in each ImageView-(void) adduiscrollview{//1. Load Uiscrollview,    and batch add Uiimageview, each imageview in a picture uiscrollview *scrollview = [[Uiscrollview alloc] init];    The visible area size of the display scrollview.frame = Self.view.bounds; Horizontal scroll bar Scrollview.showshorizontalsCrollindicator = NO;    Paging by viewable area scrollview.pagingenabled = YES;    Scrolling range scrollview.contentsize = Cgsizemake (kpicnum * viewsize.width, 0);    The agent can listen for various types of events scrollview.delegate = self;        Added to Self.view i.e. ImageView [Self.view Addsubview:scrollview]; 2, according to the index add Kpicnum picture arranged Kpicnum ImageView to scrollview inside for (int i = 0; i<kpicnum; i++) {[Self Addimageview    Toscrollview:scrollview ATINDEX:I]; }}//custom method, load uipagecontrol-(void) adduipagecontrol{//1, load Uipagecontrol _pagecontrol = [[Uipagecontrol alloc] Init    ];    Centering is best to set center first, then set bounds _pagecontrol.center = Cgpointmake (viewsize.width * 0.5, viewsize.height * 0.95);    _pagecontrol.bounds = CGRectMake (0, 0, 100, 0);    Set Total pages _pagecontrol.numberofpages = Kpicnum; Focus ~ Load the color default color from the picture and the color of the current page _pagecontrol.pageindicatortintcolor = [Uicolor colorwithpatternimage:[uiimage imagenamed:@    "New_feature_pagecontrol_point.png"]; _pagecontrol.currentpageindicatortintcolor = [Uicolor Colorwithpatternimage:[uiimage imagenamed:@ "new_feature_pagecontrol_checked_point.png"];    Disables the default interactive event _pagecontrol.userinteractionenabled = NO; Add to Self.view i.e. ImageView [Self.view Addsubview:_pagecontrol];} The proxy method of the ScrollView is used to dynamically control the current point of the Pagecontrol, and the rolling deceleration is called (that is, ScrollView static)-(void) Scrollviewdidenddecelerating: ( Uiscrollview *) scrollview{//The current page is the offset x divided by the width of the single sheet _pagecontrol.currentpage = Scrollview.contentoffset.x/scrollview. Frame.size.width;} Custom method, add Kpicnum image according to index Kpicnum ImageView to ScrollView-(void) Addimageviewtoscrollview: (Uiscrollview *)    ScrollView atindex: (int) i{//1. Create ImageView Uiimageview *imageview = [[Uiimageview alloc] init];            Because it is a horizontal arrangement, the frame is calculated from the index, and the structure must be strongly converted to cgrect Imageview.frame = (cgrect) {{i * viewsize.width, 0}, viewsize};    2. Set picture NSString *name = [NSString stringwithformat:@ "New_feature_%d.png", i + 1];        Use the method in the classification, if it is iphone5, load the picture of -568h imageview.image = [UIImage fullscrennimagenamed:name];3. Add [ScrollView Addsubview:imageview]; 4. If it is the last picture, add 2 buttons (share, start) if (i = = kPicNum-1) {//must make the last ImageView can be clicked so that 2 buttons inside it can be clicked ImageView.                        userinteractionenabled = YES;        The last picture page, there are two buttons, one is to start [self addstartbtninimageview:imageview];    The last picture page, there are two buttons, the other is to share the microblogging button, the default is selected [self addsharebtninimageview:imageview];  }}//Last picture page, there are two buttons, one is share-(void) Addsharebtninimageview: (Uiimageview *) imageview{//2.1. Create a custom style button _sharebtn =    [UIButton Buttonwithtype:uibuttontypecustom];        Added to the last sheet of ImageView [ImageView addsubview:_sharebtn]; 2.2. Set the button background picture//Call yourself to write the classification method, set the button normal and highlight the status of the background picture, and return the size of the picture cgsize sharebtnnormalbgimgsize = [_sharebtn setbtnbgimgfor        normalandselectedwithname:@ "New_feature_share_false.png" selectedname:@ "New_feature_share_true.png"];    2.3. Border (center, first center, rear bounds) _sharebtn.center = Cgpointmake (viewsize.width * 0.5, viewsize.height * 0.75); The button is wide, just press the background picture width high _sHarebtn.bounds = (cgrect) {cgpointzero, sharebtnnormalbgimgsize};    2.4. Monitor [_sharebtn addtarget:self action: @selector (Sharebtnclick:) forcontrolevents:uicontroleventtouchupinside];    2.5. Do not change the picture color _sharebtn.adjustsimagewhenhighlighted = no;    2.6. Default check _sharebtn.selected = YES;    }//Share button Click event, as long as the switch different selected state, you can display different two pictures (normal picture is not checked, the selected picture is checked)-(void) Sharebtnclick: (UIButton *) sharebtn{ sharebtn.selected =!sharebtn.isselected;}    The last picture page, there are two buttons, one is start-(void) Addstartbtninimageview: (Uiimageview *) imageview{//1.1. Create an Open button//use a custom style    UIButton *startbtn = [UIButton buttonwithtype:uibuttontypecustom];            Added to the last sheet of ImageView [ImageView addsubview:startbtn]; 1.2. Set the background image and other personality styles//Call yourself to write the classification method, set the button normal and highlight the status of the background picture, and return the size of the picture cgsize startbtnbgimgsize = [Startbtn setbtnbgimgfornorm    alandhighightedwithname:@ "New_feature_finish_button.png"];    1.3. Border Startbtn.center = Cgpointmake (viewsize.width * 0.5, viewsize.height * 0.85); ButtonThe width and height of the background picture is as large as Startbtn.bounds = (cgrect) {cgpointzero, startbtnbgimgsize};    1.4. Monitor [startbtn addtarget:self action: @selector (Startbtnclick) forcontrolevents:uicontroleventtouchupinside]; }//When you click the Start button, call block to complete the following functions: Initialize the host controller to become the root controller of the window-(void) startbtnclick{//Directly call block (that is, a piece of code inside another class to execute) if (_startblock    ) {_startblock (_sharebtn.isselected); }} @end







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.