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 location 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]; The first index starting from 0       uiview* Aview=[[uiview alloc] Initwithframe:cgrectmake (a);    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 just know, did not do nib file to the Xxxviewcontroler Program Association, hereby recorded: 1, open nib File 2, click "File ' Owner", press COMMAND+4, set class to XxxViewControler3, Press control+ "Files ' Owner", there is a default Iboutlet variable view, see if there is no link in the back, if not pull to the following view and views to do 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 say "processing", of course, Uiviewcontroller itself is not aware of user interaction, which requires UIView user interaction (for example: touchesbegintouchesmoved) passed up. Generally used in two ways to accomplish this pass: 1, [self nextresponder] touchesbegin:touches ... 2, using notification no matter in which 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=25;    Usermodel.sex=yes;            twocontroller* Twocroller=[[twocontroller Alloc]init];   Don't write it like that, or pass it to empty, because there is 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),

The concept of didfinishlaunchingwithoptions

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 bar Self.window = [[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease];  CGRect bound = [[UIScreen mainscreen]bounds];     Returns a rect NSLog (@ "boundwith:%f boundheight:%f", bound.size.width,bound.size.height) with a status bar;     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 D  INKMIXER[599:C07] boundx:0.000000 boundy:0.000000 cgrect appbound = [[UIScreen mainscreen]applicationframe];     Returns a rect NSLog (@ "appboundwith:%f boundheight:%f", appbound.size.width,appbound.size.height) without a status bar;    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//very clearly status bar Takes up space 20 pixels masterviewcontroller *masterviewcontroller = [[[Masterviewcontroller alloc] initwithnibname:@ "MasterViewCo Ntroller "Bundle:nil" autorelease];//creates a view controller based on the name of the nib file Self.navigationcontroller = [[[Uinavigationcontroller] Alloc] Initwithrootviewcontroller:masterviewcontroller] autorelease];//Create a navigation controller, and specifies that the navigation controller's root view controller is the above established masterviewcontroller Self.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 display the Windows window that contains the View Controller view on the screen. return YES;}

30: @property properties for various data types

A. Memory management nsstring:copy Basic data types, structs (int, cgfloat, BOOL, CGRect, etc.): Assign objects such as custom model types, Nsarray, Nsdictionary): Strong control: Weak other details: Atomic and nonatomicatomic mean setter/getter This function is a primitive operation. If more than one thread calls the setter at the same time, one thread does not appear before the entire setter statement, and the other thread starts executing the setter condition, which is equivalent to the function's end and end lock. Nonatomic does not guarantee the setter/getter of the original line, so you may be able to take something incomplete. For example, the setter function changes two member variables, if you use Nonatomic, the getter may be taken to change only one of the variables when the state, so that the problem of what to take. If you do not need multi-threading support, of course, nonatomic is sufficient, and because it does not involve the lock operation, so it does relatively fast atomic: The default is the property, this property is to ensure that the program in multithreaded situations, the compiler will automatically generate some mutex lock code, Avoid read and write synchronization of this variable. Nonatomic: If the object does not need to consider multithreading, add this property, which will allow the compiler to generate a few mutually exclusive lock code, can improve efficiency. ReadWrite and Readonlyreadwrite: This property is the default and will automatically generate accessors for you. ReadOnly: Only getter Generation does not have setter methods. The real value of the two properties of ReadWrite, ReadOnly, is not to provide a member variable access interface, but to control access to member variables. Strong and Weakstrong: Strong references, which we usually refer to, determine the survival of the object directly. If there is no reference to an object and the object no longer appears in the list, the object is freed from memory. Weak: Weak references do not determine the survival of an object. Even if an object is held with countless weak references, it is cleared if no strong references point to it. Pointer set to Nil;strong and retain function similar, weak and assign similar, only when the object disappears weak will automatically change the pointer to Nil;assign, copy, retainassign: Default type, setter method directly assigned value, Do not perform any retain operations without changing the reference count. Typically used to handle basic data types. Retain: Releases the old object (release), and the old object'sValue is assigned to the new object, and the new object reference count is 1. I understand that as a copy of the pointer, copy the original pointer, release the contents of the object pointed to by the original pointer, and then point the pointer to the new object content. Copy: As with the retain process, release the old value first, and then copy the new object, Retaincount to 1. The mechanism introduced to reduce dependency on the context. I understand a copy of the content, request a piece of space into memory, assign the original object content to it, and make its reference count 1. Pay special attention to the Copy property: the object defined with the Copy property must conform to the Nscopying protocol and must implement the-(ID) Copywithzone: (Nszone *) Zone method. can also be used directly:

31: Hide status bar (status bar), Navigationbar (navigation bar), Tabbarcontroller (tab bar)

Hide status bar (status bar) [[[UIApplication sharedapplication] setstatusbarhidden:yes]; hide Navigationbar (navigation bar) [ Self.navigationcontroller Setnavigationbarhidden:yes Animated:yes]; Hide tabbarcontroller (tab bar)   size changed to more than 480 OK. [Self.tabBarController.view setframe:cgrectmake (0, 0, 320, 520)];

32: Good site collection

http://www.baigoogledu.comhttp://nshipster.cn/http://objccn.io/https://github.com/Xuzz/newsychttps:// Github.com/mmackh/hacker-news-for-ios

iOS Development Basics-Fragmentation 5

Related Article

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.