iPhone UITableViewCell: repositioning the textLabel

前端 未结 5 2034
终归单人心
终归单人心 2020-12-25 12:00

I am new to iPhone development and I am currently working on a simple RSS reader app. The problem I am having is that I need to reposition the textLabel inside

5条回答
  •  独厮守ぢ
    2020-12-25 12:15

    You can create a subclass for UITableViewCell and customize de textLabel frame. See that answer: Labels aligning in UITableViewCell. It's works perfectly to me.

    It's my subclass

    #import "UITableViewCellFixed.h"
    @implementation UITableViewCellFixed
    - (void) layoutSubviews {
         [super layoutSubviews];
         self.textLabel.frame = CGRectMake(0, 0, 320, 20);
    }
    @end
    

    It's my UITableViewControllerClass:

    UITableViewCellFixed *cell = (UITableViewCellFixed *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCellFixed alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    

提交回复
热议问题