iOS Development Basics-Fragmentation 2

Source: Internet
Author: User

Six: Get another control and implement a jump

uistoryboard* Mainstoryboard = [Uistoryboard storyboardwithname:@ "mainstoryboard"  Bundle:nil];   *registerviewcontroller = [Mainstoryboard instantiateviewcontrollerwithidentifier:@ "  Registerviewcontroller"];         = uimodaltransitionstylecoververtical;    [Self presentviewcontroller:registerviewcontroller animated:yes completion:^{        NSLog (@ "  Present Modal View");    }];

Where Registerviewcontroller is the value that identifies the Inspector storyboard ID in the second view

Seven: Determine the iOS version

Determine if iOS is 7.0 or later

if ([[[[Uidevice Currentdevice] systemversion] floatvalue]>=7.0) {

}

Eight: button the background picture in different states

[_registerbutton setbackgroundimage:[uiimage imagenamed:@ "3signbutton-n.png"] forstate:uicontrolstatenormal];

[_registerbutton setbackgroundimage:[uiimage imagenamed:@ "3signbutton-s.png"] forstate:uicontrolstatehighlighted] ;

Nine: Determine whether the device is 3.5 inch or 4 inch

if ([[UIScreen mainscreen] Currentmode].size.height = = 480| | [[Uiscreenmainscreen] currentmode].size.height = = 960)

{

It's a 3.5-inch iphone device.

}

Else

{//This is a 4-inch iphone device}

Ten: Call in Viewdidload

Whether you create a Uiviewcontroller view by Xib file or by overriding the Loadview method, the Viewdidload method will eventually be called after the view is created, typically we do the initialization on the interface here, such as adding some sub-views to the view, loading the model data from the database or the network into the child view

-(void) viewdidload {     [super Viewdidload];           // Add a button     UIButton *button = [UIButton buttonwithtype:uibuttontypecontactadd];     [Button addtarget:self Action: @selector (click) forcontrolevents:uicontroleventtouchupinside];     [Self.view Addsubview:button]; }

11: Tree-structured navigation problem (Uinavigationcontroller)

1: How to modify the second page return back text

The first page of the viewdidload should be modified (assuming that from a interface push to the B interface, you want to change the B interface return button title, the A interface to add code), the code is as follows:

-(void*backitem =@ " return "= backitem;}

2: How to add a control to the header

In the viewdidload of this page, add the following code:

-(void) viewdidload{uibarbuttonitem* done=[[Uibarbuttonitem alloc] Initwithbarbuttonsystemitem:uibarbuttonsystemitemadd target:self Action: @selector (Downshow)]; Self.navigationItem.rightBarButtonItem= done;} -(void) downshow{}

Where the key types are as follows (with different icons):

    Uibarbuttonsystemitemdone,    uibarbuttonsystemitemcancel,    Uibarbuttonsystemitemedit,      Uibarbuttonsystemitemsave,      Uibarbuttonsystemitemadd,    uibarbuttonsystemitemflexiblespace,    Uibarbuttonsystemitemfixedspace,    uibarbuttonsystemitemcompose,    uibarbuttonsystemitemreply,    Uibarbuttonsystemitemaction,    uibarbuttonsystemitemorganize,    Uibarbuttonsystemitembookmarks,    Uibarbuttonsystemitemsearch,    Uibarbuttonsystemitemrefresh,    uibarbuttonsystemitemstop,    Uibarbuttonsystemitemcamera,    Uibarbuttonsystemitemtrash,    Uibarbuttonsystemitemplay,    Uibarbuttonsystemitempause,    Uibarbuttonsystemitemrewind,    Uibarbuttonsystemitemfastforward,    Uibarbuttonsystemitemundo,    Uibarbuttonsystemitemredo,    uibarbuttonsystemitempagecurl//  can only be displayed on toolbar

3: How to modify the color of the header

Self.navigationcontroller.navigationbar.tintcolor=[uicolor Redcolor];

4: Add other Uisegment,uiswith controls

Add the following code to the Viewdidload on this page

Uisegmentedcontrol *mysegment; Mysegment= [[Uisegmentedcontrol alloc] Initwithframe:cgrectmake (218.0f,8.0,100.0f,30.0f)]; [Mysegment insertsegmentwithtitle:@"Distribution"Atindex:0Animated:yes]; [Mysegment insertsegmentwithtitle:@"processing"Atindex:1Animated:yes]; Mysegment.segmentedcontrolstyle=Uisegmentedcontrolstylebar; Mysegment.selectedsegmentindex=0; [Self.navigationController.navigationBar addsubview:mysegment];

iOS Development Basics-Fragmentation 2

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.