gpt4 book ai didi

ios - 在 Bubble Tableview cell tap 上读取 NSBubbledata

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

我正在开发一个聊天应用程序,我正在使用 Alex Barinovs 聊天气泡 TableView 示例。我可以在气泡上添加消息和图像。但我想要的是,当我点击任何行或单元格时,我想获取我点击的特定单元格的详细信息。我有一个名为 onListTap 的方法,它是一个 UItapGestureRecognizer 方法,我可以在点击时获取 TableView 的索引路径。但是它在该单元格上返回的数据有点像这样-

    tapped cell data - <NSBubbleData: 0x7fe6c3160f10>

谁能告诉我如何读取此 (NSBubbleData) 数据以及如何识别它是哪种类型的数据(图像、文本、 View 等)。

这是我的 onListTap 方法:

- (void)onListTap:(UIGestureRecognizer*)recognizer {
if (recognizer.state == UIGestureRecognizerStateEnded) {
CGPoint tapLocation = [recognizer locationInView:_bubbleTable];
NSIndexPath *tapIndexPath = [_bubbleTable indexPathForRowAtPoint:tapLocation];
NSLog(@" tapped cell data - %@",[newMessageArray objectAtIndex: tapIndexPath.row]);

}
}

其中,newMessageArray 是我的气泡 TableView 数组。

最佳答案

检查这个,我认为它会起作用。您可以获得单元格中的文本和图像不要忘记 #import "UIBubbleTableViewCell.h"

- (void)onListTap:(UIGestureRecognizer*)recognizer {
if (recognizer.state == UIGestureRecognizerStateEnded) {
CGPoint tapLocation = [recognizer locationInView:_bubbleTable];
NSIndexPath *tapIndexPath = [_bubbleTable indexPathForRowAtPoint:tapLocation];
UIBubbleTableViewCell *cell = [_bubbleTable cellForRowAtIndexPath:tapIndexPath];
for (id Obj in cell.contentView.subviews) {
if ([Obj isKindOfClass:[UILabel class]]) {
UILabel *Lbl = (UILabel *)Obj;
NSLog(@"%@",Lbl.text);
}
if ([Obj isKindOfClass:[UIImageView class]]) {
UIImageView *Img = (UIImageView *)Obj;
//Do Something with Img.image
}
}
}
}

关于ios - 在 Bubble Tableview cell tap 上读取 NSBubbledata,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40039987/

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