gpt4 book ai didi

ios - UIBubbleTableView 从 NSBubbleData 获取 didSelectRowAtIndexPath?

转载 作者:行者123 更新时间:2023-11-29 02:53:11 24 4
gpt4 key购买 nike

嗨,我正在使用 code创建聊天 View 工作正常,但我需要在单击时添加放大图像,因此在 UIBubbleTableView.m 类中我添加了以下代码以获取索引选择值。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"value of index=%@",[NSString stringWithFormat:@"%d",indexPath.row]);
NSLog(@"value of selected section=%@",[NSString stringWithFormat:@"%@", [[self.bubbleSection objectAtIndex:indexPath.section] objectAtIndex:indexPath.row - 1]]);

}

它给出以下输出:

所选部分的值=

我如何从上面的 NSBubbleData 中获取文本或图像??

此代码中传递的数据具有以下格式

//for photo
NSBubbleData *photoBubblenew = [NSBubbleData dataWithImage:image date:[NSDate dateWithTimeIntervalSinceNow:-0] type:BubbleTypeMine];

//for text
NSBubbleData * TextBubble = [NSBubbleData dataWithText:@"Hi,Check out Iphonelover" date:[NSDate dateWithTimeIntervalSinceNow:-300] type:BubbleTypeSomeoneElse];

最佳答案

在此处放置标签 TAG...

 -(id)initWithText:(NSString *)text date:(NSDate *)date type:(NSBubbleType)type
{

UIFont *font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
CGSize size = [(text ? text : @"") sizeWithFont:font constrainedToSize:CGSizeMake(220, 9999) lineBreakMode:NSLineBreakByWordWrapping];

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
label.numberOfLines = 0;
label.lineBreakMode = NSLineBreakByWordWrapping;

label.text = (text ? text : @"");
label.font = font;
label.backgroundColor = [UIColor clearColor];
label.tag=100;

UIEdgeInsets insets = (type == BubbleTypeMine ? textInsetsMine : textInsetsSomeone);
return [self initWithView:label date:date type:type insets:insets];}

然后在此处获取值

NSBubbleData *bubble=Chat_DATA [indexPath.row];

UIView *view=bubble.view;

UILabel *LBL=(UILabel*) [view viewWithTag:100];

NSString *msg=LBL.text;

关于ios - UIBubbleTableView 从 NSBubbleData 获取 didSelectRowAtIndexPath?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24241131/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com