开发者

UITableViewCustomCell

i want to use UITableCustomCell in my application but i am invoking the custom cell开发者_如何学JAVA from another class. When i use UITableViewCell then i need to add these lines to call tableviewcells from another class

/*
SurahViewController *aBookDetail = [[SurahViewController alloc] 
                              initWithNibName:@"SurahView" bundle:nil];
self.surahViewController = aBookDetail;
[self.navigationController pushViewController:surahViewController animated:YES];
[aBookDetail release];
*/

but when i use UITableViewCustomCell in my application and i want to invoke custom table view cell from another class then there is no idea of what code to use to call that UITableCustomCell from another class.

Thank you in advance.


I'm doing it with the following code:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"UILogbookTVCell" owner:self options:nil];
    cell = tvCell;
    tvCell = nil;
}

Note that tvCell is an UITableView IBOutlet. In the UILogbookTVCell.xib the File's Owner is the UITableViewController implementation, and the UITableViewCell element is connected to the tvCell IBOutlet. Therefore the NSBundle loadNibNamed sets the property tvCell, which can then be set to the local cell and cleared.

This is also the official variant as described in the Table View Programming Guide.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜