Six: Get another control and implement a jump
uistoryboard* Mainstoryboard = [Uistoryboard storyboardwithname:@ "Mainstoryboard" bundle:nil]; Uiviewcontroller *registerviewcontroller = [Mainstoryboard instantiateviewcontrollerwithidentifier:@] Registerviewcontroller "]; Registerviewcontroller.modaltransitionstyle = uimodaltransitionstylecoververtical; [Self presentviewcontroller:registerviewcontroller animated:yes completion:^{ NSLog (@ "Present Modal View"); }];
Another way to connect with segue:
If there is a segue between the current Viewcontroller in storyboard and the Viewcontroller to jump, you can execute Performseguewithidentifier:sender: This method implements the jump.
For example:[self performseguewithidentifier:@ ' go ' sender: self];
Where go defines the segue identifier for itself.
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) Viewdidload{uibarbuttonitem *backitem = [[[[[Uibarbuttonitem alloc] init] autorelease]; backitem.title = @ "return"; Self.navigationItem.backBarButtonItem = 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:0 Animated:yes]; [Mysegment insertsegmentwithtitle:@ "Processing" atindex:1 Animated:yes]; Mysegment.segmentedcontrolstyle = Uisegmentedcontrolstylebar; Mysegment.selectedsegmentindex = 0; [Self.navigationController.navigationBar addsubview:mysegment];
iOS Development Basics-Fragmentation 2