gpt4 book ai didi

ios - 在 UITableView 中为 iOS 中的聊天应用程序创建一个气泡

转载 作者:行者123 更新时间:2023-11-29 00:48:59 29 4
gpt4 key购买 nike

我正在尝试在我的 UITableview 中创建一个 UIBubbleTableView。我在互联网上搜索了一个示例并尝试了完全相同的事情。但是这个例子使用了 xib,而我使用的是 storyboard。我已将示例中给出的文件导入到我的项目中。但是当我尝试运行该代码时,它崩溃了。-

-[UITableView setBubbleDataSource:]: unrecognized selector sent to instance

下面是我尝试过的。

@interface ChatController (){

IBOutlet UIView *textView;
IBOutlet UITextField *textF1;
NSMutableArray *bubbleData1;
IBOutlet UIBubbleTableView *bubbleTbl;
}

-(void)viewDidLoad {
[super viewDidLoad];

//bubble data
NSBubbleData *heyBubble1 = [NSBubbleData dataWithText:@"Hey, halloween is soon" date:[NSDate dateWithTimeIntervalSinceNow:-300] type:BubbleTypeSomeoneElse];
heyBubble1.avatar = [UIImage imageNamed:@"avatar1.png"];

NSBubbleData *photoBubble1 = [NSBubbleData dataWithImage:[UIImage imageNamed:@"halloween.jpg"] date:[NSDate dateWithTimeIntervalSinceNow:-290] type:BubbleTypeSomeoneElse];
photoBubble1.avatar = [UIImage imageNamed:@"avatar1.png"];

NSBubbleData *replyBubble1 = [NSBubbleData dataWithText:@"Wow.. Really cool picture out there. iPhone 5 has really nice camera, yeah?" date:[NSDate dateWithTimeIntervalSinceNow:-5] type:BubbleTypeMine];
replyBubble1.avatar = nil;

bubbleData1 = [[NSMutableArray alloc] initWithObjects:heyBubble1, photoBubble1, replyBubble1, nil];
bubbleTbl.bubbleDataSource = self;
}

应用程序在此行崩溃。 - bubbleTbl.bubbleDataSource = self;

我尝试将“bubbleTbl” socket 连接到我的tableview,但无法连接它,因此我不知道如何将bubbleDataSource'设置为我的表格 View

谁能帮帮我。感谢任何帮助

编辑-

我已经实现了这个方法,并在这个方法上设置了断点。但这个方法永远不会被执行。

- (NSInteger)rowsForBubbleTable:(UIBubbleTableView *)tableView
{

NSLog(@"bubble count %lu",(unsigned long)[bubbleData1 count]);
return [bubbleData1 count];
}

编辑2-

在气泡中显示视频的代码-

UIEdgeInsets insetss = { .left = 180, .right = 10, .top =10, .bottom = 200 };
NSBubbleData *videodata=[NSBubbleData dataWithView:_playerViewController.view date:[NSDate dateWithTimeIntervalSinceNow:0] type:BubbleTypeMine insets:(insetss)];
[bubbleData1 addObject:videodata];

编辑3--

NSString *stringVideoName = @"videobuild.mov";
NSString *stringVideoPath = [[NSBundle mainBundle] pathForResource:stringVideoName ofType:nil];
NSAssert(stringVideoPath, @"Expected not nil video file");

NSURL *urlVideoFile = [NSURL fileURLWithPath:stringVideoPath];
NSAssert(urlVideoFile, @"Expected not nil video url");

_playerViewController = [[AVPlayerViewController alloc] init];
_playerViewController.player = [AVPlayer playerWithURL:urlVideoFile];
_playerViewController.view.frame = CGRectMake(10.0, 0.0, 150.0 , 80.0); // self.view.bounds;
_playerViewController.showsPlaybackControls = YES;

最佳答案

在类的UITableView中添加xib/storyboard - UIBubbleTableView

enter image description here

关于ios - 在 UITableView 中为 iOS 中的聊天应用程序创建一个气泡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38326211/

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