您的位置:首页 > 产品设计 > UI/UE

iOS开发之UITableViewCell的官方文档库

2015-09-28 11:18 246 查看
UITableViewCell 继承自UIView,是UITableView的重要组件。

一下是截取的官方文档:

NS_CLASS_***AILABLE_IOS(2_0)
@interface UITableViewCell :
UIView <NSCoding,
UIGestureRecognizerDelegate>

// Designated initializer. If the cell can be reused, you must pass in a reuse identifier. You should use the same reuse identifier for all cells of the same form.
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString
*)reuseIdentifier NS_***AILABLE_IOS(3_0);

// Content. These properties provide direct access to the internal label and image views used by the table view cell. These should be used instead of the content properties below.

@property (nonatomic,
readonly,
retain) UIImageView *imageView
NS_***AILABLE_IOS(3_0);
// default is nil. image view will be created if necessary.

@property (nonatomic,
readonly,
retain) UILabel *textLabel
NS_***AILABLE_IOS(3_0);
// default is nil. label will be created if necessary.

@property (nonatomic,
readonly,
retain) UILabel *detailTextLabel
NS_***AILABLE_IOS(3_0);
// default is nil. label will be created if necessary (and the current style supports a detail label).

// If you want to customize cells by simply adding additional views, you should add them to the content view so they will be positioned appropriately as the cell transitions into and out of editing mode.

@property (nonatomic,
readonly, retain)
UIView *contentView;

// Default is nil for cells in UITableViewStylePlain, and non-nil for UITableViewStyleGrouped. The 'backgroundView' will be added as a subview behind all other views.
@property (nonatomic,
retain) UIView *backgroundView;

// Default is nil for cells in UITableViewStylePlain, and non-nil for UITableViewStyleGrouped. The 'selectedBackgroundView' will be added as a subview directly above the backgroundView if not nil, or behind all other views. It is added as a subview only when
the cell is selected. Calling -setSelected:animated: will cause the 'selectedBackgroundView' to animate in and out with an alpha fade.
@property (nonatomic,
retain) UIView *selectedBackgroundView;

// If not nil, takes the place of the selectedBackgroundView when using multiple selection.
@property (nonatomic,
retain) UIView *multipleSelectionBackgroundView
NS_***AILABLE_IOS(5_0);

@property (nonatomic,
readonly, copy)
NSString *reuseIdentifier;

- (void)prepareForReuse;
// if the cell is reusable (has a reuse identifier), this is called just before the cell is returned from the table view method dequeueReusableCellWithIdentifier:. If you override, you MUST call super.

@property (nonatomic)
UITableViewCellSelectionStyle selectionStyle;
// default is UITableViewCellSelectionStyleBlue.

@property (nonatomic,
getter=isSelected)
BOOL selected;
// set selected state (title, image, background). default is NO. animated is NO

@property (nonatomic,
getter=isHighlighted)
BOOL highlighted;
// set highlighted state (title, image, background). default is NO. animated is NO
- (void)setSelected:(BOOL)selected animated:(BOOL)animated;
// animate between regular and selected state
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated;
// animate between regular and highlighted state

@property (nonatomic,
readonly)
UITableViewCellEditingStyle editingStyle;
// default is UITableViewCellEditingStyleNone. This is set by UITableView using the delegate's value for cells who customize their appearance accordingly.
@property (nonatomic)
BOOL showsReorderControl;
// default is NO

@property (nonatomic)
BOOL shouldIndentWhileEditing;
// default is YES. This is unrelated to the indentation level below.

@property (nonatomic)
UITableViewCellAccessoryType accessoryType;
// default is UITableViewCellAccessoryNone. use to set standard type

@property (nonatomic,
retain)
UIView *accessoryView;
// if set, use custom view. ignore accessoryType. tracks if enabled can calls accessory action

@property (nonatomic)
UITableViewCellAccessoryType editingAccessoryType;
// default is UITableViewCellAccessoryNone. use to set standard type

@property (nonatomic,
retain)
UIView *editingAccessoryView;
// if set, use custom view. ignore editingAccessoryType. tracks if enabled can calls accessory action

@property (nonatomic)
NSInteger indentationLevel;
// adjust content indent. default is 0
@property (nonatomic)
CGFloat indentationWidth;
// width for each level. default is 10.0
@property (nonatomic)
UIEdgeInsets separatorInset
NS_***AILABLE_IOS(7_0)
UI_APPEARANCE_SELECTOR;
// allows customization of the separator frame

@property (nonatomic,
getter=isEditing)
BOOL editing;
// show appropriate edit controls (+/- & reorder). By default -setEditing: calls setEditing:animated: with NO for animated.
- (void)setEditing:(BOOL)editing animated:(BOOL)animated;

@property(nonatomic,
readonly) BOOL showingDeleteConfirmation;
// currently showing "Delete" button

// These methods can be used by subclasses to animate additional changes to the cell when the cell is changing state

// Note that when the cell is swiped, the cell will be transitioned into the UITableViewCellStateShowingDeleteConfirmationMask state,

// but the UITableViewCellStateShowingEditControlMask will not be set.
- (void)willTransitionToState:(UITableViewCellStateMask)state
NS_***AILABLE_IOS(3_0);
- (void)didTransitionToState:(UITableViewCellStateMask)state
NS_***AILABLE_IOS(3_0);

@end

@interface UITableViewCell (UIDeprecated)

// Frame is ignored. The size will be specified by the table view width and row height.
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier
NS_DEPRECATED_IOS(2_0,
3_0);

// Content properties. These properties were deprecated in iPhone OS 3.0. The textLabel and imageView properties above should be used instead.

// For selected attributes, set the highlighted attributes on the textLabel and imageView.
@property (nonatomic,
copy) NSString *text
NS_DEPRECATED_IOS(2_0,
3_0);
// default is nil
@property (nonatomic,
retain) UIFont *font
NS_DEPRECATED_IOS(2_0,
3_0);
// default is nil (Use default font)
@property (nonatomic)
NSTextAlignment textAlignment
NS_DEPRECATED_IOS(2_0,
3_0); // default is UITextAlignmentLeft
@property (nonatomic)
NSLineBreakMode lineBreakMode
NS_DEPRECATED_IOS(2_0,
3_0); // default is UILineBreakModeTailTruncation
@property (nonatomic,
retain) UIColor *textColor
NS_DEPRECATED_IOS(2_0,
3_0);
// default is nil (text draws black)
@property (nonatomic,
retain) UIColor *selectedTextColor
NS_DEPRECATED_IOS(2_0,
3_0); // default is nil (text draws white)

@property (nonatomic,
retain)
UIImage *image
NS_DEPRECATED_IOS(2_0,
3_0);
// default is nil. appears on left next to title.
@property (nonatomic,
retain) UIImage *selectedImage
NS_DEPRECATED_IOS(2_0,
3_0);
// default is nil

// Use the new editingAccessoryType and editingAccessoryView instead
@property (nonatomic)
BOOL hidesAccessoryWhenEditing
NS_DEPRECATED_IOS(2_0,
3_0); // default is YES

// Use the table view data source method -tableView:commitEditingStyle:forRowAtIndexPath: or the table view delegate method -tableView:accessoryButtonTappedForRowWithIndexPath: instead

@property (nonatomic,
assign)
id target
NS_DEPRECATED_IOS(2_0,
3_0);
// target for insert/delete/accessory clicks. default is nil (i.e. go up responder chain). weak reference

@property (nonatomic)
SEL editAction
NS_DEPRECATED_IOS(2_0,
3_0);
// action to call on insert/delete call. set by UITableView

@property (nonatomic)
SEL accessoryAction
NS_DEPRECATED_IOS(2_0,
3_0);
// action to call on accessory view clicked. set by UITableView

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: