<span id="Label3"></p> <ul> <ul> <li>plist file <ul> <li>Root: represents what type of data is stored<pre><code> 如果root是array, 那么将来从文件中读取进来的就是数组 plist中的每一个item就代表着数组中的一个元素 item对应的类型, 就代表数组中每一个元素的类型</code></pre></li> <li>The name of the custom plist file cannot contain the word info because the system configuration is Info.plist</li>Get plist file path <ul> <li>NSString *path = [[nsbundle mainbundle] pathforresource:@ "shops.plist" oftype:nil];</li> </ul> </ul></li> </ul> </ul> <ul> <ul> <li><p>Dictionary Turn model</p> <ul> <li><p>Reason:</p> <ul> <li><p>Data is not generally obtained directly from the dictionary in development</p> <ul> <li>1. The key of the dictionary is a string, the error will not be incorrect</li> <li>2. English is not good, words can't remember</li> <li>3. Since key is a string, there is no hint when encoding</li> </ul></li> <li><p>To solve this problem, we can use objects to hold the data, the object is to store the data, then I call this object model</p></li> <li>Rule: whenever you see a dictionary in development, you will typically create a corresponding model to hold the data in the Dictionary.</li> <li>Dictionary array in dictionary array cannot use KVC for dictionary conversion model</li> <li>General Steps: <ul> <li>1. Get the absolute path to the plist file</li> <li>2. Load the plist file according to the path</li> <li>3. Convert all dictionaries in the array to models</li> </ul></li> </ul></li> </ul></li> </ul> </ul> <ul> <li><li><p>Custom View</p> <ul> <li>To customize the View: <ul> <li>1. Overriding initialization method (one-time initialization Inside) xib:awakefromnib Pure code: initWithFrame</li> <li>2. Rewrite layoutsubviews, layout child controls inside</li> <li>3. Receive incoming data from outside, override set method</li> </ul></li> <li>Attention: <ul> <li>If you customize a view, it is not recommended to set the location of the child controls in the Init method because the parent Control's frame is not taken in the Init method if the child Control's position needs to be computed from the parent Control's frame</li> </ul></li> <li>Attention: <ul> <li>In general, Customizing a control overrides the Control's initWithFrame method, because the user may be created through the Init method or by the initWithFrame method, in order to ensure that the child controls can be added regardless of which method the user Creates. So overriding the Initwithframe,init method internally calls initWithFrame</li> </ul></li> <li>Attention: <ul> <li>If you create an object in a class method, it is recommended that you use self, do not use the class name if you use the class name directly, and you cannot create a subclass object with a subclass because the parent class has already been written Dead.</li> </ul></li> <li>Layoutsubviews <ul> <li>Location specifically for layout child controls</li> <li>Overriding the Layoutsubviews method, be sure to call the [super layoutsubviews] method if not called, there will be some wonderful mistakes</li> </ul></li> <li>overriding model set <ul> <li>Set data for child controls</li> </ul></li> </ul></li></li> <li><li><p>Reasons to save the control using Week:</p> <ul> <li>As soon as you add an object to the parent control, the subviews array in the parent control will strongly reference this control</li> </ul></li></li> </ul> <ul> <li>Xib <ul> <li><li>Xib and storyboard are all used to describe the Interface.</li></li> <li><li>Xib is the predecessor of Storyboard.</li></li> <li><li>Xib is used to describe a simple interface or a local interface.</li></li> <li><li>Storyboard is used to describe the overall</li></li> <li><li>Get the Xib method.</li></li> <li><li>Nibname: xib name bundle to load: from which package to find</li></li> <li><pre><pre> <code class="lang-objc">-<span class="hljs-number">1.uinib *nib = [uinib nibwithnibname: <span class="hljs-string">@ "shopview" bundle:[<span class="hljs-built_in">nsbundle mainbundle]];-create All the interfaces described in Xib Span class= "hljs-built_in" >nsarray *res = [nib instantiatewithowner:<span class="hljs-literal">nil Options:<span class="hljs-literal">nil]; [<span class="hljs-keyword">self<span class="hljs-variable">.shopsview addsubview:res <span class="hljs-variable">.firstobject]; <span class="hljs-number">2.<span class="hljs-built_in">nsarray *res = [[<span class="hljs-built_in">NSBundle mainbundle] loadnibnamed:<span class="hljs-string">@ "shopview" owner:<span class="hljs-literal">nil Options:<span class="hljs-literal">nil]; [<span class="hljs-keyword">self<span class="hljs-variable">.shopsview addsubview:res <span class="hljs-variable">.firstobject]; </span> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span> </span></span></span></span></span></span></code></pre></pre></li> <li><li>Xib Loading Principle: <ul> <li>1. Create the object according to the custom class Jxshopview *shopview = [jxshopview alloc] init];</li> <li>2. Set the relevant properties of the control according to the settings in xib Shopview.backgroundcolor = [uicolor redcolor]; Shopview.frame = CGR ectmake (0, 0, 70, 100);</li> <li>3. Create all child controls, and set the properties of the child controls</li> <li>Uiimageview <em>IV = [[uiimageview alloc] init];</em></li> <li><em>Iv.frame = CGRectMake (0, 0, 70, 70);</em></li> <li><em>UILabel </em>label = [[UILabel alloc] init];</li> <li>Label.frame = CGRectMake (0, 70, 70, 30);</li> <li>4. Check if the child control has a connection, and if so, Associate Self.iconview = iv; Self.namelabel = label;</li> <li>5. Add all child controls to the parent control [shopview addsubview:iv]; [shopview addsubview:label];</li> </ul></li></li> <li><li>Attention: <ul> <li>If you create a control by Xib or storyboard, the initWithFrame method is not called</li> <li>If you create a control through Xib or storyboard, the Initwithcoder method is called when it is created, and the control is not necessarily created when the method is Called.</li> <li>If you are creating a control through Xib or storyboard, after "created" calls awakefromnib, when the method is called, it proves that the control has been created.</li> </ul></li></li> </ul></li> </ul><p><p>IOS UI Basics 03</p></p></span>
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