iOS Development Basics-Fragmentation 5

Source: Internet
Author: User

23: Addsubview and Insertsubview differences

Addsubview is the topmost layer that adds the view to all layers equivalent to setting the Insertsubview atindex parameter to View.subviews count, which is [view Addsubview:oneview]==[View Insertsubview:oneview atIndex:view.subviews Count]addsubview is added to the last Insertsubview is added to the specified position UIView* View=[[uiview Alloc] Initwithframe:cgrectmake (0.0,0.0,30.0,50.0)]; View.backgroundcolor=[Uicolor Redcolor];        [Self.view Addsubview:view]; UIView* Newview=[[uiview Alloc] Initwithframe:cgrectmake ( -,0, +, -)]; Newview.backgroundcolor=[Uicolor Bluecolor];    [Self.view Addsubview:newview]; UIView* Twoview=[[uiview Alloc] Initwithframe:cgrectmake (0, -, -, $)]; Twoview.backgroundcolor=[Uicolor Yellowcolor]; [Self.view Addsubview:twoview]; //first Index starting from 0UIView* Aview=[[uiview Alloc] Initwithframe:cgrectmake ( -, -, -, $)]; Aview.backgroundcolor=[Uicolor Graycolor]; [Self.view insertsubview:aview Atindex:2];

24: Loaded the "Xxxview" nib but the view outlet is not set solution  

' -[uiviewcontroller _loadviewfromnibnamed:bundle:] Loaded the "Xxxview" nib but the view outlet is not set. ' Check the book only know, did not do nib file to the Xxxviewcontroler Program Association, hereby recorded: 1 , open the nib file 2, click "File ' s Owner", press command+4, set class to Xxxviewcontroler  3, according to control+"Files ' Owner", there is a default Iboutlet variable view, see if there is any link in the back, If not, pull to the following view and views to make an association

25: Uiviewcontroller and UIView relations

Uiviewcontroller is the view controller, UIView is the view, Uiviewcontroller is to control UIView. Uiviewcontroller is like a container, it can operate on its internal objects, UIView is the object in the container, a container can have a lot of objects; UIView works on the front lines, showing the user the content of the presentation and accepting the user's interaction. Uiviewcontroller equivalent to the director, according to the plan of the UIView in the form of the show, which contains some fancy tricks, such as flipping, fading and so on. Another function of Uivewcontroller is to handle user interaction, note here I'm talking about " handling "12  , using notification regardless of the way, if Uiviewcontroller get the user's input, then it should make some changes to UIView in response to the user's input, Here to note that Uiviewcontroller should only change the performance of UIView, and should not deal with other things, more operations through the delegate to do, about the delegate of the application of the next message to explain the way of delivery together. 

26: Page pass-through problem

if you want to upload from a to B, you can simply define a property in B, and then assign it to the page before it jumps, to achieve a jump; UserInfo* usermodel=[[UserInfo alloc] init]; Usermodel.username=Self.textBox1.text; Usermodel.age= -; Usermodel.sex=YES; //twocontroller* Twocroller=[[twocontroller Alloc]init];don't write like that, or pass it on empty, because there's no connection between views Twocontroller* twocroller= [[Uistoryboard storyboardwithname:@"Mainstoryboard"Bundle:nil] Instantiateviewcontrollerwithidentifier:@"Twocontroller"]; //define the view of page B as an identity TwocontrollerTwocroller.newuserinfo =Usermodel; [Self Presentviewcontroller:twocroller animated:yes completion:nil]; If you jump from a to page B and then transfer the value from page B to page A, you can use the delegate method;


27: Collection View and Table view

The collection view is not the same as some of the concepts of the table view, such as a section, and the method of implementing the delegate is different;


28: Jump through the Segue logo

[Self performseguewithidentifier:@ "Twosegue" sender:self];
Where push cannot jump directly from Viewcontroller to Viewcontroller;

29: UIScreen (screen), UIWindow (picture frame), UIView (canvas), didfinishlaunchingwithoptions concept

//Didfinishlaunchingwithoptions method: As the name implies. The inside method is called when the app starts running. -(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions{//returns a rectangle with the status barSelf.window =[[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease]; CGRect bound= [[UIScreen mainscreen]bounds];//returns a rect with the status barNSLog (@"boundwith:%f boundheight:%f", Bound.size.width,bound.size.height); NSLog (@"boundx:%f boundy:%f", BOUND.ORIGIN.X,BOUND.ORIGIN.Y); //2012-08-03 23:21:45.716 dinkmixer[599:c07] boundwith:320.000000 boundheight:480.000000//2012-08-03 23:21:45.719 dinkmixer[599:c07] boundx:0.000000 boundy:0.000000CGRect Appbound= [[UIScreen mainscreen]applicationframe];//returns a rect that does not have a status barNSLog (@"appboundwith:%f boundheight:%f", Appbound.size.width,appbound.size.height); NSLog (@"appboundx:%f boundy:%f", APPBOUND.ORIGIN.X,APPBOUND.ORIGIN.Y); //2012-08-03 23:21:45.720 dinkmixer[599:c07] appboundwith:320.000000 boundheight:460.000000//2012-08-03 23:21:45.720 dinkmixer[599:c07] appboundx:0.000000 boundy:20.000000//It's obvious that the status bar occupies 20 pixels of space.Masterviewcontroller*masterviewcontroller = [[[Masterviewcontroller alloc] Initwithnibname:@"Masterviewcontroller"Bundle:nil] autorelease];//Create a view controller based on the name of the nib fileSelf.navigationcontroller= [[[Uinavigationcontroller alloc] initwithrootviewcontroller:masterviewcontroller] autorelease];//Create a navigation controller and specify the navigation controller's root view controller for the Masterviewcontroller created aboveSelf.window.rootViewController= Self.navigationcontroller;//the form (window) has a root view controller-This view controller is responsible for configuring the view that appears first when the form is displayed. To make the contents of your view controller appear in the form, you need to set the form's root view controller as your view controller. [Self.window makekeyandvisible];//This line of code will show the window that contains the View Controller view on the screen.     returnYES;}

iOS Development Basics-Fragmentation 5

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.