我想调整 UITableViewCell 的默认 textLabel 的大小,因为我在行的右侧显示图像。我试过这段代码,但它不起作用,我不明白为什么。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//...
cell.textLabel.frame = CGRectMake(5, 5, 100, 50);
//...
}
最佳答案
你应该使用自定义标签
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
UILabel *Lbl = [[UILabel alloc]initWithFrame:CGRectMake(75.0f, 4.5f, 360.0f, 20.0f)];
[cell.contentView addSubview:Lbl];
[Lbl release];
}
关于iphone - 如何调整 cell.textLabel 的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7551940/