开发者

Selected state of custom UITableViewCell

I've got a table with custom cells brought in from an IB file. Cell is created like this:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


    static NSString *MyIdentifier = @"MyIdentifier";
    MyIdentifier = @"BasicCell";

    BasicCell *cell = (BasicCell *)[tableView dequeueReusableCellWithIdentifier开发者_运维问答:MyIdentifier];
    if(cell == nil) {
        [[NSBundle mainBundle] loadNibNamed:@"BasicCell" owner:self options:nil];
        cell = basicCell;
    }

    [cell setLabelText:@"Test"];


return cell;
}

The cell is designed to look like a jazzed up version of the rounded table style (diff colors, gradients etc). It's really a plain style table, with custom graphics. From the users perspective, it doesn't lie flush to the left and right of the view.

When I select the cell, how do I get it to change to another custom cell design from IB? At the moment, it just shows a blue standard selection thing behind an image view that I'm using within the cell nib. Because I'm trying to copy the rounded style table look, I guess I would need three versions of the table cell - top rounded, standard, and bottom rounded.


You wont be able to change the cell to another design from IB because that would require for it to recreate itself (you prolly actually could but it wouldnt look good and it would prolly be hackerish)...however you can have many different content view defined in IB and declare them all in a cell subclass (which u can tie to your IB as well), then you can just hide views and show views depending on the selection state...you can do this in the selected method of UITableView cell heres a ref tableviewcell ref.. hope that helps

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜