1.今天学习了UITableViewCell的有关属性。没有牵扯自定义的Cell。我们就先来看看UITableViewCell的有关属性和使用方法。
1.- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
NSString *cellIndentifiter = @"CellIndentifiter";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentifiter];
2.如图
@property (nonatomic, readonly, retain) UIImageView *imageView
3.如图
@property (nonatomic, readonly, retain) UILabel *textLabel NS_AVAILABLE_IOS(3_0);
4.如图
@property (nonatomic, readonly, retain) UILabel *detailTextLabel
NSString *textfont =[self.array objectAtIndex:row];
cell.textLabel.font = [UIFont fontWithName:textfont size:20];
cell.textLabel.text = textfont;
cell.detailTextLabel.text = @"detailText";
cell.imageView.image = [UIImage imageNamed:@"1.png"];
//------------
5.
// 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;
6.
// 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;
7.
@property (nonatomic, retain) UIView *selectedBackgroundView;
8.
// If not nil, takes the place of the selectedBackgroundView when using multiple selection.
@property (nonatomic, retain) UIView *multipleSelectionBackgroundView NS_AVAILABLE_IOS(5_0);
9.
@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.
10.
@property (nonatomic) UITableViewCellSelectionStyle selectionStyle;
11.
@property (nonatomic, getter=isSelected) BOOL selected;
12.
@property (nonatomic, getter=isHighlighted) BOOL highlighted;
13。
- (void)setSelected:(BOOL)selected animated:(BOOL)animated;
14.
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated;
15.
@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.
16.
@property (nonatomic) UITableViewCellAccessoryType accessoryType; // default is UITableViewCellAccessoryNone. use to set standard type
typedef NS_ENUM(NSInteger, UITableViewCellAccessoryType) {
UITableViewCellAccessoryNone, // don't show any accessory view
UITableViewCellAccessoryDisclosureIndicator, // regular chevron. doesn't track
UITableViewCellAccessoryDetailDisclosureButton, // info button w/ chevron. tracks
UITableViewCellAccessoryCheckmark, // checkmark. doesn't track
UITableViewCellAccessoryDetailButton NS_ENUM_AVAILABLE_IOS(7_0) // info button. tracks
};
//-----------------
17.
@property (nonatomic, retain) UIView *accessoryView; // if set, use custom view. ignore accessoryType. tracks if enabled can calls accessory action
//accessoryView 是可以设置的,但是 xy的位置是固定不可变的。和accessoryType 所处的位置相同,但是如果改变view的宽高,还是可以改变的。
18.
@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
19
@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_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR; // allows customization of the separator frame
20
@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;
21
@property(nonatomic, readonly) BOOL showingDeleteConfirmation; // currently showing "Delete" button
22
// 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_AVAILABLE_IOS(3_0);
- (void)didTransitionToState:(UITableViewCellStateMask)state NS_AVAILABLE_IOS(3_0);
typedef NS_OPTIONS(NSUInteger, UITableViewCellStateMask) {
UITableViewCellStateDefaultMask = 0,
UITableViewCellStateShowingEditControlMask = 1 << 0,
UITableViewCellStateShowingDeleteConfirmationMask = 1 << 1
};