这是我的CustomCoordinatesCell.h文件:
#import <UIKit/UIKit.h>
@interface CoordinatesCustomCell : UITableViewController
@property (weak, nonatomic) IBOutlet UILabel *index;
@property (weak, nonatomic) IBOutlet UILabel *latitude;
@property (weak, nonatomic) IBOutlet UILabel *longitude;
@end
但是,在我的CustomCoordinatesCell.m文件中,当我将@synthesize用于纬度和经度时,例如@synthesize latitude = _latitude,这是可行的。但是,当我为index属性尝试此操作时,它给了我一个错误:
属性实现必须在接口“ CoordinatesCustomCell”中声明
但是,我的CoordinatesCustomCell.h文件中的索引IS的属性
这是我的CustomCoordinateCell.m文件:
#import "CoordinatesCustomCell.h"
@implementation CoordinatesCustomCell
@synthesize latitude = _latitude;
@synthesize longitude = _longitude;
@synthesize index = _index;
//@synthesize coordinateNumber = _coordinateNumber;
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
您不再需要@synthesize
声明。
您不小心将单元格声明为子类,UITableViewController
而不是UITableViewCell
。
还要确保您cell
正确声明并强制转换以访问其自定义属性:
CustomCoordinateCell *cell = (CustomCoordinateCell *)[tableview dequeueReusableCellWithIdentifiee:identifier forIndexPath:indexPath];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句