UITableViewCell use in iOS

Source: Internet
Author: User
<span id="Label3"></p>UITableViewCell use in iOS<p><p>-(instancetype) initwithstyle: (uitableviewcellstyle) style reuseidentifier: (nsstring*) reuseidentifier;</p></p><p><p>Cell initialization method, You can set a style and identifier, the style of enumeration is as Follows:</p></p>? <table border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="gutter">123456</td> <td class="code"><code class="cpp keyword bold"><code class="cpp keyword bold">typedef</code></code><code class="cpp plain"><code class="cpp plain">NS_ENUM(NSInteger, UITableViewCellStyle) {</code></code><code class="cpp spaces"><code class="cpp spaces">    </code></code><code class="cpp plain"><code class="cpp plain">UITableViewCellStyleDefault,    </code></code><code class="cpp comments"><code class="cpp comments">// 默认风格,自带标题和一个图片视图,图片在左</code></code><code class="cpp spaces"><code class="cpp spaces">    </code></code><code class="cpp plain"><code class="cpp plain">UITableViewCellStyleValue1,     </code></code><code class="cpp comments"><code class="cpp comments">// 只有标题和副标题 副标题在右边</code></code><code class="cpp spaces"><code class="cpp spaces">    </code></code><code class="cpp plain"><code class="cpp plain">UITableViewCellStyleValue2,     </code></code><code class="cpp comments"><code class="cpp comments">// 只有标题和副标题,副标题在左边标题的下边</code></code><code class="cpp spaces"><code class="cpp spaces">    </code></code><code class="cpp plain"><code class="cpp plain">UITableViewCellStyleSubtitle    </code></code><code class="cpp comments"><code class="cpp comments">// 自带图片视图和主副标题,主副标题都在左边,副标题在下</code></code><code class="cpp plain"><code class="cpp plain">};</code></code></td> </tr> </tbody> </table><p><p></p></p><p><p>@property (nonatomic, readonly, retain) uiimageview *imageview;</p></p><p><p>Picture view, style is only created when allowed</p></p><p><p>@property (nonatomic, readonly, retain) UILabel *textlabel;</p></p><p><p>Title label</p></p><p><p></p></p><p><p>@property (nonatomic, readonly, retain) UILabel *detailtextlabel;</p></p><p><p><span>Subtitle Label</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>@property (nonatomic, readonly, retain) UIView *contentview;</p></p><p><p><span>To accommodate the view, any child view of the cell should be added to this</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>@property (nonatomic, Retain) UIView *backgroundview;</p></p><p><p><span>Background view</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>@property (nonatomic, Retain) UIView *selectedbackgroundview;</p></p><p><p><span>Background view in selected state</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>@property (nonatomic, Retain) UIView *multipleselectionbackgroundview;</p></p><p><p><span>Background view when multiple selections are selected</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>@property (nonatomic, readonly, copy) nsstring *reuseidentifier;</p></p><p><p><span>The identifier of the cell</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>-(void) prepareforreuse;</p></p><p><p><span>This method is called when the cell that is being reused is going to be displayed, and the most important aspect of this method is that when you have a picture on your custom cell, the image can be garbled (when the image comes from an asynchronous download and its obvious), and then we can rewrite the method to erase the Content.</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>@property (nonatomic) Uitableviewcellselectionstyle selectionstyle;</p></p><p><p><span>The style of the cell when it is selected is enumerated as Follows:</span></p></p>? <table border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="gutter">123456 </td> <td class="code">< Code class= "cpp keyword bold" >typedef  <code class="cpp plain">ns_enum (nsinteger,  Uitableviewcellselectionstyle)  {</code> <code class="cpp spaces">     </code> <code class="cpp plain">uitableviewcellselectionstylenone, </code> <code class="cpp comments">//none </code> <code class="cpp spaces">     </code> <code class="cpp plain">uitableviewcellselectionstyleblue, </code> <code class="cpp comments">//blue </code> <code class="cpp spaces">     </code> <code class="cpp plain">uitableviewcellselectionstylegray, </code> <code class="cpp comments">//gray </code> <code class="cpp spaces">     </code> <code class="cpp plain">uitableviewcellselectionstyledefault </code> <code class="cpp comments">//default   Blue </code> <code class="cpp plain" }; < code> </code></td> </tr> </tbody> </table><p><p></p></p><p><p>@property (nonatomic, getter=isselected) BOOL selected;</p></p><p><p><span>Set cell Check Status</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>@property (nonatomic, getter=ishighlighted) BOOL highlighted;</p></p><p><p><span>Sets whether the cell is in a highlighted state</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>-(void) setselected: (bool) selected Animated: (bool) animated;</p></p><p><p>-(void) sethighlighted: (bool) highlighted animated: (bool) animated;</p></p><p><p><span>Corresponds to the above two attributes</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>@property (nonatomic, readonly) Uitableviewcelleditingstyle editingstyle;</p></p><p><p><span>Gets the edit state of the cell, enumerated as follows</span></p></p>? <table border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="gutter">12345</td> <td class="code"><code class="cpp keyword bold">typedef</code><code class="cpp plain">NS_ENUM(NSInteger, UITableViewCellEditingStyle) {</code><code class="cpp spaces">    </code><code class="cpp plain">UITableViewCellEditingStyleNone,</code><code class="cpp comments">//无编辑</code><code class="cpp spaces">    </code><code class="cpp plain">UITableViewCellEditingStyleDelete,</code><code class="cpp comments">//删除编辑</code><code class="cpp spaces">    </code><code class="cpp plain">UITableViewCellEditingStyleInsert</code><code class="cpp comments">//插入编辑</code><code class="cpp plain">};</code></td> </tr> </tbody> </table><p><p></p></p><p><p></p></p><p><p>@property (nonatomic) BOOL showsreordercontrol;</p></p><p><p>Sets whether to show the Auto-sort control that comes with the cell</p></p><p><p>Note: to allow the cell to implement the drag sort function, in addition to the above set to yes, you also need to implement the following methods in the Proxy:</p></p><p><p></p></p><p><p>-(BOOL) tableView: (uitableview *) tableView canmoverowatindexpath: (nsindexpath *) indexpath{</p></p><p><p>Return YES;</p></p><p><p>}</p></p><p><p>-(void) tableView: (uitableview *) tableView moverowatindexpath: (nsindexpath*) sourceindexpath toindexpath: ( Nsindexpath *) destinationindexpath{</p></p><p><p></p></p><p><p>}</p></p><p><p></p></p><p><p></p></p><p><p>@property (nonatomic) BOOL shouldindentwhileediting;</p></p><p><p>Set whether indentation is displayed in edit state</p></p><p><p></p></p><p><p>@property (nonatomic) Uitableviewcellaccessorytype accessorytype;</p></p><p><p><span>Set the style of the attachment View (the view that appears at the far right of the CELL) is enumerated as Follows:</span></p></p>? <table border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="gutter">1234567</td> <td class="code"><code class="cpp keyword bold"><code class="cpp keyword bold">typedef</code></code><code class="cpp plain"><code class="cpp plain">NS_ENUM(NSInteger, UITableViewCellAccessoryType) {</code></code><code class="cpp spaces"><code class="cpp spaces">    </code></code><code class="cpp plain"><code class="cpp plain">UITableViewCellAccessoryNone,                   </code></code><code class="cpp comments"><code class="cpp comments">// 没有视图</code></code><code class="cpp spaces"><code class="cpp spaces">    </code></code><code class="cpp plain"><code class="cpp plain">UITableViewCellAccessoryDisclosureIndicator,    </code></code><code class="cpp comments"><code class="cpp comments">// cell右侧显示一个灰色箭头</code></code><code class="cpp spaces"><code class="cpp spaces">    </code></code><code class="cpp plain"><code class="cpp plain">UITableViewCellAccessoryDetailDisclosureButton, </code></code><code class="cpp comments"><code class="cpp comments">// 显示详情符号和灰色箭头</code></code><code class="cpp spaces"><code class="cpp spaces">    </code></code><code class="cpp plain"><code class="cpp plain">UITableViewCellAccessoryCheckmark,              </code></code><code class="cpp comments"><code class="cpp comments">// cell右侧显示蓝色对号</code></code><code class="cpp spaces"><code class="cpp spaces">    </code></code><code class="cpp plain"><code class="cpp plain">UITableViewCellAccessoryDetailButton  </code></code><code class="cpp comments"><code class="cpp comments">// cell右侧显示一个详情符号</code></code><code class="cpp plain"><code class="cpp plain">};</code></code></td> </tr> </tbody> </table><p><p></p></p><p><p>@property (nonatomic, Retain) UIView *accessoryview;</p></p><p><p><span>Attachment view</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>@property (nonatomic) Uitableviewcellaccessorytype editingaccessorytype;</p></p><p><p><span>The attachment view style when cell editing</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>@property (nonatomic, Retain) UIView *editingaccessoryview;</p></p><p><p><span>Attachment <span>View</span> when cell is being edited</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>@property (nonatomic) Nsinteger indentationlevel;</p></p><p><p><span>Set the indentation level for a content area</span></p></p><p><p></p></p><p><p>@property (nonatomic) cgfloat indentationwidth;</p></p><p><p><span>Set the indentation width for each level</span></p></p><p><p></p></p><p><p>@property (nonatomic) uiedgeinsets separatorinset;</p></p><p><p><span>Set the offset of a split line</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>@property (nonatomic, Getter=isediting) BOOL editing;</p></p><p><p>-(void) setediting: (bool) editing animated: (bool) animated;</p></p><p><p><span>Set whether to edit state</span></p></p><p><p></p></p><p><p>@property (nonatomic, readonly) BOOL showingdeleteconfirmation;</p></p><p><p><span>Returns whether the Delete button is currently being displayed</span></p></p><p><p><span></span></p></p><p><p></p></p><p><p>-(void) willtransitiontostate: (uitableviewcellstatemask) state;</p></p><p><p><span>The function called when the cell state is about to be converted can be overridden in a subclass</span></p></p><p><p>-(void) didtransitiontostate: (uitableviewcellstatemask) state;</p></p><p><p><span>A function that is called when the cell state has been converted can be overridden in a subclass with the following status enumeration:</span></p></p>? <table border="0" cellspacing="0" cellpadding="0"> <tbody> <tr> <td class="gutter">12345</td> <td class="code"><code class="cpp keyword bold">typedef </code>  <code class="cpp plain">ns_options ( Nsuinteger, uitableviewcellstatemask)  {</code> <code class="cpp spaces">     </code> <code class="cpp plain">uitableviewcellstatedefaultmask                      = 0, </code> <code class="cpp comments">//default State </code> <code class="cpp spaces">     </code> <code class="cpp plain">uitableviewcellstateshowingeditcontrolmask           = 1 << 0, </code> <code class="cpp comments">//edit status </code> <code class="cpp spaces">     </code> <code class="cpp plain">uitableviewcellstateshowingdeleteconfirmationmask   = 1 < < 1 </code> <code class="cpp comments">//confirm deletion status </code> <code class="cpp plain">}; </code> </td> </tr> </tbody> </table><p><p></p></p><p><p><span>Note: The following methods have all been discarded after IOS3.0, although there are effects, but will be warned</span></p></p><p><p></p></p><p><p>@property (nonatomic, copy) nsstring *text;</p></p><p><p><span>Set Title<br></span></p></p><p><p></p></p><p><p>@property (nonatomic, Retain) Uifont *font;</p></p><p><p><span>Set font<br></span></p></p><p><p></p></p><p><p>@property (nonatomic) nstextalignment textalignment;</p></p><p><p><span>Set the mode to its</span></p></p><p><p></p></p><p><p>@property (nonatomic) Nslinebreakmode linebreakmode;</p></p><p><p><span>Set the break mode</span></p></p><p><p></p></p><p><p>@property (nonatomic, Retain) Uicolor *textcolor;</p></p><p><p><span>Set Font Color<br></span></p></p><p><p></p></p><p><p>@property (nonatomic, Retain) Uicolor *selectedtextcolor;</p></p><p><p><span>Set the font color for the selected state</span></p></p><p><p></p></p><p><p>@property (nonatomic, Retain) UIImage *image;</p></p><p><p><span>Set up a picture<br></span></p></p><p><p></p></p><p><p>@property (nonatomic, Retain) UIImage *selectedimage;</p></p><p><p><span>Set the picture when selected<br></span></p></p><p><p></p></p><p><p>@property (nonatomic) BOOL hidesaccessorywhenediting;</p></p><p><p><span>Whether to hide attachment view when editing<br></span></p></p><p><p>UITableViewCell use in iOS</p></p></span>

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.