NSString在3.0中的UITableViewCell中被过早切断,但在3.1中看起来还不错 [英] NSString is cut off prematurely in a UITableViewCell in 3.0, but looks fine in 3.1

查看:40
本文介绍了NSString在3.0中的UITableViewCell中被过早切断,但在3.1中看起来还不错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UITableViewCellStyleValue2UITableViewStyleGrouped.

让我们从一些代码开始(它还不是100%完整,但是我试图包含希望破译我正在做的事情,甚至可能做错的事情所需的代码):

Let's start with some code (it's not 100% complete, but I have tried to include the code needed to hopefully decipher what I am doing, and maybe doing wrong):

#define CELL_FONTSIZE 15.0f
CGSize textSizeValue2 = {207.0f, 9999.0f};

if ([value isEqual: CELL_4]) {
     CGSize   size = [cell4String sizeWithFont:[UIFont boldSystemFontOfSize:CELL_FONTSIZE] constrainedToSize:textSizeValue2 lineBreakMode:UILineBreakModeWordWrap];
     size.height += CELL_HEIGHT;          // top and bottom margin
     result = MAX(size.height, 44.0f);  // at least one row

对于这个特定的单元格,对于3.0和3.1,高度的结果均为214

For this particular cell, the result for the height comes out to 214 both for 3.0 and 3.1

这是该单元格的代码:

static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
    cell.textLabel.numberOfLines = 0;
    cell.detailTextLabel.numberOfLines = 0;
    cell.clearsContextBeforeDrawing;

if ([value isEqual: CELL_4]) {
        cell.textLabel.text = @"About";
        cell.detailTextLabel.text = cell4String;

因此,基本上,对于3.0和3.1,确实发生了同样的事情,但是在3.0模拟器中运行该应用程序时,如果cell.detailTextLabel.numberOfLines包含三行以上的文本,则最后一行似乎会被切断.奇怪的是,文本只是被剪切掉了,但是在3.0中以正确的高度绘制了单元格,单元格下面只有一个很大的空白.

So basically, for 3.0 and 3.1 the exact same thing is happening, but when running the app in 3.0 simulator, the last line seems to get cut off if the cell.detailTextLabel.numberOfLines has more than three lines of text. The strange thing is that the text is just cut off, but the cell is drawn at the correct height in 3.0, there's just a big blank whitespace underneath the cell.

任何人都知道为什么3.0和3.1之间有区别吗?我知道我正在使用Xcode的Beta版本,但是很奇怪,它只能在Beta版本中使用,而不能在3.0版本中使用,因为据我所知,我并没有做任何疯狂的事情,而是做一些基本的事情.

Anyone know why this is different between 3.0 and 3.1 ? I know I am using a beta of Xcode, but it's pretty strange that it works in the beta and not in 3.0 because, as far as I can see, I am not doing anything too crazy, but something basic.

谢谢

推荐答案

好,我没有答案或解决方案.但是我只是想指出我面临着同样的问题.我以为我会让你知道,你不是唯一的一个,那也许是值得的.

Well, I don't have an answer or solution. But I just wanted to point out I'm facing the same issues. I thought I'd let you know that you're not the only one, that's probably worth something.

我正在使用安装了3.0 iPhone SDK(不是beta)的Xcode 3.1.3. 空白空间"同时出现在模拟器和运行固件3.0的设备上.我没有尝试过较新的版本.

I'm using Xcode 3.1.3 with the 3.0 iPhone SDK installed (not a beta). The "blank space" appears both in the simulator and on the device both running firmware 3.0. I haven't tried a more recent version.

这篇关于NSString在3.0中的UITableViewCell中被过早切断,但在3.1中看起来还不错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆