开发者

Delete confirmation button in UITableView overlaps the content

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

    static NSString *LogCellId = @"LogCellId";
    UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:LogCellId];

    UILabel *lblSummary;

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:LogCellId] autorelease];   
        lblSummary = [[[UILabel alloc] initWithFrame:CGRectMake(10.0, 10.0, 320.0, 30.0)] autorelease];
        lblSummary.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
        lblSummary.tag = SUMMARY_TAG;
        lblSummary.lineBreakMode = UILineBreakModeTailTruncation;
    开发者_如何学Go    lblSummary.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;

        [cell.contentView addSubview:lblSummary];
    } else {
        lblSummary = (UILabel *)[cell viewWithTag:SUMMARY_TAG];
    }

    lblSummary.text = [self.logList objectAtIndex:[indexPath row]];

    return cell;
}

What I have there is just a simple cell with one label. I have added swipe-to-delete functionality but the delete button overlaps the label, not pushing it to side.

So I need help. I would appreciate an answer on how I would do this one and also how the autoresizing masks work. I do not feel comfortable with them at all, neither when or where I should use the autoresizing subviews.

Thank you for your time.


Try combining different masks with the C bitwise OR operator: |. Experiment with the different masks, maybe this works:

lblSummary.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin;

Autoresizing masks are used when a UIView needs to be resized. By for instance using UIViewAutoresizingFlexibleLeftMargin, you tell the view that you would like it to expand or shrink from or to that left margin, but not reposition the margin.

You would set UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin like this in IB:

Delete confirmation button in UITableView overlaps the content

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜