Whether iOS exists in the project, the reflection that is used that little thing

Source: Internet
Author: User

Nsclassfromstring,nsselectorfromstring,iskingofclass

1. nsclassfromstring

This method determines whether the class exists, and if it is present, it is loaded dynamically, and returns an empty object if it is not saved.

ID MYOBJ = [[Nsclassfromstring (@ "Myspecialclass") alloc] init];

Normally equivalent to: id MYOBJ = [[Myspecialclass alloc] init];

Advantages:

1, weaken the connection, so does not link the absence of the framework to the program.

2, import is not required because the class is dynamically loaded and can be loaded as long as it exists. So if you do not have a header file definition for a class in your toolchain, and you are sure that the class is available, you can use this method.

2. nsselectorfromstring

This method complements the previous method and is also a dynamic loading instance method.

Sel sel = nsselectorfromstring (@ "Dosomethingmethod:")//Note the colon, indicating that the method has parameters

if ([object Respondstoselector:sel]) {

[Object Performselector:sel Withobject:color]; Note If there are two parameters, use two withobject: parameter;

}

3. Iskindofclass

Iskindofclass we can also use Iskindofclass to check whether an object is a member of a class


4. Ismemberofclass

The Ismemberofclass method is to determine whether an object is a member of a class

  

5. The difference between Initwithcoder and initWithFrame  Initwithcoder is called when a class is created in IB but is instantiated in Xocdde. For example, create a controller's nib file with IB, Then the controller is instantiated by Initwithnibname in XOCDE, and the controller's initwithcoder is called.

initWithFrame is a user-created UIView subclass that is called when an instance is

6. UIView Autoresizingmask

If the view's Autoresizessubviews property declaration is set to Yes, its child view is automatically resized based on the value of the Autoresizingmask property. Simply configuring the automatic sizing mask for the view often allows the application to get the appropriate behavior, otherwise the application must provide its own implementation by overloading the Layoutsubviews method.

Self.autoresizingmask = uiviewautoresizingflexiblewidth;//If the constant is set, the width of the view will change proportionally with the width of the parent view. Otherwise, the width of the view remains the same.

  

Uiviewautoresizingnone

If this constant is set, the view will not be automatically resized.

Uiviewautoresizingflexibleheight

If this constant is set, the height of the view will change proportionally with the height of the parent view. Otherwise, the view's height will remain unchanged.

Uiviewautoresizingflexiblewidth

If this constant is set, the width of the view will change proportionally with the width of the parent view. Otherwise, the width of the view remains the same.

Uiviewautoresizingflexibleleftmargin

If this constant is set, the left edge of the view adjusts proportionally as the width of the parent view changes. Otherwise, the relative position of the view and its parent view's left edge remains the same.

Uiviewautoresizingflexiblerightmargin

If this constant is set, the right edge of the view adjusts proportionally as the width of the parent view changes. Otherwise, the relative position of the right edge of the view and its parent view remains the same.

Uiviewautoresizingflexiblebottommargin

If this constant is set, the bottom edge of the view adjusts proportionally as the height of the parent view changes. Otherwise, the relative position of the bottom boundary of the view and its parent view remains unchanged.

Uiviewautoresizingflexibletopmargin

If this constant is set, the top bounds of the view will adjust proportionally as the parent view height changes. Otherwise, the relative position of the top boundary of the view and its parent view remains unchanged.


Whether iOS exists in the project, the reflection that is used that little thing

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.