我正在 iOS 6 中编写一个应用程序。这是 ViewController.m 文件中的一段代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"CustomCellIdentifier"];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
cell = _customCell;
_customCell = nil;
}
cell.firstName.textLabel = @"dsdsds";
cell.middleName.textLabel = @"N/A";
cell.lastName.textLabel = @"daasdsdasa";
return cell;
}
这些代码行给了我错误(Property 'firstName' not found on object of type 'CustomCell*'
):
cell.firstName.textLabel = @"dsdsds";
cell.middleName.textLabel = @"N/A";
cell.lastName.textLabel = @"daasdsdasa";
客户单元.h:
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *firstName;
@property (strong, nonatomic) IBOutlet UILabel *middleName;
@property (strong, nonatomic) IBOutlet UILabel *lastName;
+(NSString*) reuseIdentifier;
@end
In the Outlets of CustomCell.xib:
firstName -> label
middleName -> label
lastName -> label
Referencing Outlets:
customCell -> File's Owner
Selecting the firstName label:
Referencing Outlets:
firstName -> CustomCell
firstName -> CustomCell -CustomCellIdentifier
Selecting the middleName label:
lastName -> Custom Cell - CustomCellIdentifier
middleName -> Custom Cell
Selecting the lastName label:
lastName -> Custom Cell
middleName -> Custom Cell- Custom Cell Identifier
那么,问题是什么?在我看来,这与奥特莱斯有关。