Iphone UITableviewcell集属性
我需要在uitableviewcell中设置属性。下面的代码和我一样编写 myTableViewCell.hIphone UITableviewcell集属性,iphone,objective-c,uitableview,Iphone,Objective C,Uitableview,我需要在uitableviewcell中设置属性。下面的代码和我一样编写 myTableViewCell.h @interface myTableViewCell : UITableViewCell @property (nonatomic, weak) NSString *row; @property (nonatomic, weak) NSString *section; myTableViewCell.m - (id)initWithStyle:(UITableViewCellStyl
@interface myTableViewCell : UITableViewCell
@property (nonatomic, weak) NSString *row;
@property (nonatomic, weak) NSString *section;
myTableViewCell.m
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
NSLog(@"%@",_row);
}
return self;
}
myTableViewController.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
myTableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[myTableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
cell.row = [NSString stringWithFormat:@"%i",indexPath.row];
结果行=nill。有什么问题吗?在设置之前,您正在记录
\u行。只有在调用initWithStyle:reuseIdentifier:
您正在记录\u row
之后,才能设置它。只有在调用initWithStyle:reuseIdentifier:
您正在记录\u row
之后,才能设置它。只有在调用initWithStyle:reuseIdentifier:
您正在记录\u row
之后,才能设置它。在调用initWithStyle:reuseIdentifier:
之后才设置它。更好的是,它们应该是NSUInteger
属性。更好的是,它们应该是NSUInteger
属性。更好的是,它们应该是NSUInteger
属性。