ammy1 ammy1 - 4 months ago 27
iOS Question

creating a bubble in UITableView for chat application in iOS

I am trying to create a

UIBubbleTableView
in my
UITableview
. I searched an example on the internet and tried exactly the same thing. But the example used xib, and i am using
storyboard
.
I have imported the file given in example in my project. But when i try to run that code, it gets crashed saying.-


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


Here below is what i tried.

@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;
}


the app crashes on this line. -
bubbleTbl.bubbleDataSource = self
;

I tried to connect the 'bubbleTbl' outlet to my
tableview
, But couldn't connect it hence i don't know how to 'set
bubbleDataSource
' to my
Tableview
.

Can anyone please help me out. Any help is appreciated

EDIT-

I have implemented this method and have set a breakpoint on this method. But this method never gets executed.

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

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


EDIT 2-

code for showing video in bubble-

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];


EDIT 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;

Answer

Add in xib/storyboard to UITableView in class - UIBubbleTableView

enter image description here