2013-06-02 30 views
5

Tôi có hai lớp con tùy chỉnh của UITableViewCell mà Xcode không thích. Tôi đang cố gắng gọi phương thức registerClass: forReuseIdentifier: như vậy:Không đăng ký các lớp con tùy chỉnh của UITableViewCell

static NSString* gameCellIdentifier = @"GameCell"; 
static NSString* buttonCellIdentifier = @"ButtonCell"; 
// Register the classes for use. 
[self.tableView registerClass:ButtonCell forCellReuseIdentifier:buttonCellIdentifier]; 
[self.tableView registerClass:GameCell forCellReuseIdentifier:gameCellIdentifier]; 

Và tôi nhận được lỗi "Tên giao diện bất ngờ ... biểu thức mong muốn thay thế". lỗi. Bất kỳ ý tưởng?

Trả lời

8

Bạn cần phải gửi một Class-registerClass:forCellReuseIdentifier: vì vậy bạn cần phải làm điều này:

[self.tableView registerClass:[ButtonCell class] forCellReuseIdentifier:buttonCellIdentifier]; 
[self.tableView registerClass:[GameCell class] forCellReuseIdentifier:gameCellIdentifier]; 

Chúc may mắn!

1

Đừng bận tâm, tôi đã tìm ra. Tôi chỉ cần làm [ButtonCell class] để thay thế.

+0

Vậy đó! Tôi không thấy điều này cho đến khi tôi đăng câu trả lời của mình ... – Daniel

Các vấn đề liên quan