作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
嗨,我正在使用 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/
我正在制作一个 iOS 聊天应用程序。我使用 UIBubbleTableView 来显示文本和图像。 现在,我希望图像可以点击并移动到另一个 View (人们可以看到它的全尺寸)。但是 UIBubbl
Ian 将 UIBubbleTableView 用于聊天应用程序。它运行良好,但我不想显示日期和时间。有帮助吗? 下面是我的代码: NSBubbleData *heyBubble = [NSBubb
嗨,我正在使用 code创建聊天 View 工作正常,但我需要在单击时添加放大图像,因此在 UIBubbleTableView.m 类中我添加了以下代码以获取索引选择值。 - (void)tableV
我的想法已经用完了,希望社区中的某个人能给我一些建议。我目前正在使用 UIBubbleTableView ( http://alexbarinov.github.io/UIBubbleTableVie
我是一名优秀的程序员,十分优秀!