【发布时间】:2013-01-30 04:24:11
【问题描述】:
我正在使用 iOS 6 编写应用程序。 这是 ViewController.m 文件中的 sn-p 代码:
- (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";
CustomeCell.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
那么,问题是什么?在我看来,这与奥特莱斯有关。
【问题讨论】:
-
你在.m类中合成了这些属性吗
-
如果iOS6不需要综合属性
-
事实上我无法在 hat 文件中合成它们,因为首先它必须在 .h 文件中声明。虽然现在它在不同的文件中
-
什么是文件的所有者类,该类的
customCell属性是 CustomCell 还是 UITableViewCell ? -
你
#import "CustomCell.h"了吗?
标签: ios objective-c viewcontroller iboutlet outlet