【发布时间】:2016-11-14 12:54:44
【问题描述】:
我正在尝试在我的UITableview 中创建一个UIBubbleTableView。我在互联网上搜索了一个示例并尝试了完全相同的事情。但是这个例子使用了xib,我使用的是storyboard。
我已经在我的项目中导入了示例中给出的文件。但是当我尝试运行该代码时,它会崩溃说。-
-[UITableView setBubbleDataSource:]: 无法识别的选择器发送到实例
下面是我尝试过的。
@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”插座连接到我的tableview,但无法连接,因此我不知道如何“设置bubbleDataSource”到我的Tableview。
谁能帮帮我。任何帮助表示赞赏
编辑-
我已经实现了这个方法并在这个方法上设置了一个断点。但是这个方法永远不会被执行。
- (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;
【问题讨论】:
标签: ios uitableview datasource uibubbletableview