如果应用程序直接在设备上编译,它工作正常。但是在创建ipa文件并通过iTunes安装时,在iOS 4.2中,聊天气泡的高度超出了所需的大小并导致聊天重叠气泡。但它在iOS 5中工作正常。这是什么原因?提前感谢。
编辑:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *dict = (NSDictionary *)[messages objectAtIndex:indexPath.row];
NSString *msg = [[dict objectForKey:@"message"] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
CGSize textSize = { 260.0, 10000.0 };
CGSize size = [msg sizeWithFont:[UIFont boldSystemFontOfSize:13]
constrainedToSize:textSize
lineBreakMode:UILineBreakModeWordWrap];
size.height += padding*3;
CGFloat height = size.height < 65 ? 65 : size.height;
return height;
}
编辑2:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MessageCellIdentifier";
SMMessageViewTableCell *cell = (SMMessageViewTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[SMMessageViewTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if ([messages count]>0) {
NSLog(@"index path is %d",indexPath.row);
NSDictionary *s = (NSDictionary *) [messages objectAtIndex:indexPath.row];
NSString *sender =allTrim([s objectForKey:@"sender"]);
NSString *senderId = [s objectForKey:@"friendId"];
NSString *message = [s objectForKey:@"message"];
if ([message length]<8)
{
message=[message stringByAppendingString:@" "];
}
message=[message stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *time = [s objectForKey:@"time"];
NSString *locatn = [s objectForKey:@"friendLocation"];
CGSize textSize = { 260.0, 10000.0 };
CGSize size = [message sizeWithFont:[UIFont boldSystemFontOfSize:13]
constrainedToSize:textSize
lineBreakMode:UILineBreakModeWordWrap];
size.width += (padding/2);
cell.messageContentView.text = [message stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.userInteractionEnabled = YES;
cell.selectionStyle=UITableViewCellSelectionStyleNone;
UIImage *bgImage = nil;
if ([senderId isEqualToString:UIAppDelegate.userId]) {
sender=@"Me";
bgImage = [[UIImage imageNamed:@"ChatBubbleGray.png"] stretchableImageWithLeftCapWidth:24 topCapHeight:15];
[cell.messageContentView setFrame:CGRectMake(padding, padding*2, size.width, size.height)];
[cell.bgImageView setFrame:CGRectMake( cell.messageContentView.frame.origin.x - padding/2,
cell.messageContentView.frame.origin.y - padding/2,
size.width+padding,
size.height+padding)];
cell.senderAndTimeLabel.textAlignment=UITextAlignmentLeft;
} else {
bgImage = [[UIImage imageNamed:@"ChatBubbleGreen.png"] stretchableImageWithLeftCapWidth:24 topCapHeight:15];
[cell.messageContentView setFrame:CGRectMake(320 - size.width - padding,
padding*2,
size.width,
size.height)];
[cell.bgImageView setFrame:CGRectMake(cell.messageContentView.frame.origin.x - padding/2,
cell.messageContentView.frame.origin.y - padding/2,
size.width+padding,
size.height+padding)];
cell.senderAndTimeLabel.textAlignment=UITextAlignmentRight;
}
cell.bgImageView.image = bgImage;
if ([locatn length]>0)
{
cell.senderAndTimeLabel.text = [NSString stringWithFormat:@"%@, %@ %@", sender, locatn, time];
}
cell.senderAndTimeLabel.text = [NSString stringWithFormat:@"%@, %@", sender, time];
}
return cell;
}
答案 0 :(得分:0)
您是否尝试过直接构建版本?通常,直接编译是在未应用优化的情况下完成的。我从来没有听说过这种情况,但有些优化可能会让你的观点变得糟透。
答案 1 :(得分:0)
我根据教程
构建了[...]
你的第一个编程错误。 ;)
除了开玩笑之外,运行非调试可执行文件会导致应用程序具有未初始化的非归零堆,其中包含实例变量值。如果不初始化所有实例变量,可能会导致不可预测的行为。这可能是一个问题,但我们无法看到所涉及的所有代码,因此我们只能赌注可能出错的问题。你所附的代码似乎不是问题所在。这是破裂的气泡图。