开发者

Hierarchical UITableview

In my first view I have a UITableView with 5 records. In UITableView cells are holding two differen开发者_Go百科t components. One UILabel is text and another UILabel shows value for that cell.

On selection of this UITableViewCell user is navigated to another view where I have given a picker controller for changing the value of 2nd label in the table view for the selected row. I reload the UITableView data on -viewWillAppear but this overlaps the text on lables as many times I visit it.

Can anyone give me relevant example of hierarchical tableview where UItableViewCell's right section is dependant on selection of picker from next view.


I think you are adding the labels on cell.contentView everytime you reload the table, but are not removing the previous ones. Thats why the overlapping is happening.

try to remove the lables

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

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    for (UIView * view in cell.contentView.subviews) {
        [view removeFromSuperview];
        view = nil;
    }
    // add your labels
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜