[UITableViewCell]附属视图管理
Managing Accessory Views
-
accessoryTypePropertyThe type of standard accessory view the cell should use (normal state).
Cell使用的标准附属视图类型
Declaration
SWIFT
var accessoryType: UITableViewCellAccessoryTypeOBJECTIVE-C
@property(nonatomic) UITableViewCellAccessoryType accessoryTypeDiscussion
附属视图显示在表格视图正常状态下的cell右。标准的附属视图包括V型揭示标;查看UITableViewCellAccessoryType关于有效的accessoryType常量的描述。默认的accessoryType为UITableViewCellAccessoryNone。如果通过accessoryView属性设置了一个自定义的附属视图,那么这个属性的默认值就会被忽略。如果cell被激活了并且附属类型为UITableViewCellAccessoryDetailDisclosureButton, 那么附属视图就会追踪触摸,当敲击发生的时候,发送给数据源对象一个tableView:accessoryButtonTappedForRowWithIndexPath:消息。
如果附属类型的图片设置给了普通和编辑两种状态,它会在状态间交替隐退,使用editingAccessoryType属性来给编辑模式期间的cell设置附属类型。如果这个属性没有同时给两个状态设置,cell便会会动画滑入或者滑出。
The accessory view appears in the right side of the cell in the table view’s normal (default) state. The standard accessory views include the disclosure chevron; for a description of valid
accessoryTypeconstants, see UITableViewCellAccessoryType. The default isUITableViewCellAccessoryNone. If a custom accessory view is set through theaccessoryViewproperty, the value of this property is ignored. If the cell is enabled and the accessory type isUITableViewCellAccessoryDetailDisclosureButton, the accessory view tracks touches and, when tapped, sends the data-source object atableView:accessoryButtonTappedForRowWithIndexPath:message.The accessory-type image cross-fades between normal and editing states if it set for both states; use the
editingAccessoryTypeproperty to set the accessory type for the cell during editing mode. If this property is not set for both states, the cell is animated to slide in or out, as necessary.Availability
Available in iOS 2.0 and later.
-
accessoryViewPropertyA view that is used, typically as a control, on the right side of the cell (normal state).
Declaration
SWIFT
var accessoryView: UIView?OBJECTIVE-C
@property(nonatomic, strong) UIView *accessoryViewDiscussion
如果这个属性的值不是nil的话,UITableViewCell类便会使用一个给予的视图作为表格视图常规状态下的附属视图;它会忽视accessoryType属性的值。 被提供的附属视图可以是controller框架或者是一个自定义的视图。附属视图显示在cell的右边
If the value of this property is not
nil, theUITableViewCellclass uses the given view for the accessory view in the table view’s normal (default) state; it ignores the value of theaccessoryTypeproperty. The provided accessory view can be a framework-provided control or label or a custom view. The accessory view appears in the right side of the cell.The accessory view cross-fades between normal and editing states if it set for both states; use the
editingAccessoryViewproperty to set the accessory view for the cell during editing mode. If this property is not set for both states, the cell is animated to slide in or out, as necessary.Availability
Available in iOS 2.0 and later.
-
editingAccessoryTypePropertyThe type of standard accessory view the cell should use in the table view’s editing state.
Declaration
SWIFT
var editingAccessoryType: UITableViewCellAccessoryTypeOBJECTIVE-C
@property(nonatomic) UITableViewCellAccessoryType editingAccessoryTypeDiscussion
The accessory view appears in the right side of the cell when the table view is in editing mode. The standard accessory views include the disclosure chevron; for a description of valid constants, see UITableViewCellAccessoryType. The default is
UITableViewCellAccessoryNone. If a custom accessory view for editing mode is set through theeditingAccessoryViewproperty, the value of this property is ignored. If the cell is enabled and the accessory type isUITableViewCellAccessoryDetailDisclosureButton, the accessory view tracks touches and, when tapped, sends the delegate object atableView:accessoryButtonTappedForRowWithIndexPath:message.The accessory type cross-fades between normal and editing states if it set for both states; use the
accessoryTypeproperty to set the accessory view for the cell during the table view’s normal state. If this property is not set for both states, the cell is animated to slide or out, as necessary.Availability
Available in iOS 3.0 and later.
-
editingAccessoryViewPropertyA view that is used typically as a control on the right side of the cell when it is in editing mode.
Declaration
SWIFT
var editingAccessoryView: UIView?OBJECTIVE-C
@property(nonatomic, strong) UIView *editingAccessoryViewDiscussion
If the value of this property is not
nil, theUITableViewCellclass uses the given view for the accessory view in the table view’s editing state; it ignores the value of theeditingAccessoryTypeproperty. The provided accessory view can be a framework-provided control or label or a custom view. The accessory view appears in the right side of the cell.The accessory type cross-fades between normal and editing states if it set for both states; use the
accessoryTypeproperty to set the accessory view for the cell during the table view’s normal state. If this property is not set for both states, the cell is animated to slide or out, as necessary.Availability
Available in iOS 3.0 and later.

浙公网安备 33010602011771号