Skip to content
This repository was archived by the owner on Mar 9, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion example/UIBubbleTableViewExample/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ - (void)keyboardWillBeHidden:(NSNotification*)aNotification
}

#pragma mark - Actions

- (void)didSelectNSBubbleDataCell:(NSBubbleData *)dataCell{
NSLog(@"Image Option");
}
- (IBAction)sayPressed:(id)sender
{
bubbleTable.typingBubble = NSBubbleTypingTypeNobody;
Expand Down
12 changes: 6 additions & 6 deletions src/NSBubbleData.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ - (id)initWithImage:(UIImage *)image date:(NSDate *)date type:(NSBubbleType)type
size.width = 220;
}

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
imageView.image = image;
imageView.layer.cornerRadius = 5.0;
imageView.layer.masksToBounds = YES;
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, size.width, size.height);
button.tag = 1;
[button setBackgroundImage:image forState:UIControlStateNormal];


#if !__has_feature(objc_arc)
[imageView autorelease];
[button autorelease];
#endif

UIEdgeInsets insets = (type == BubbleTypeMine ? imageInsetsMine : imageInsetsSomeone);
return [self initWithView:imageView date:date type:type insets:insets];
return [self initWithView:button date:date type:type insets:insets];
}

#pragma mark - Custom view bubble
Expand Down
18 changes: 17 additions & 1 deletion src/UIBubbleTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,25 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.data = data;
cell.showAvatar = self.showAvatars;

UIButton *button = (UIButton*)[data.view viewWithTag:1];
[button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside];

return cell;
}

- (void) checkButtonTapped:(id)sender event:(id)event {
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self];
NSIndexPath *indexPath = [self indexPathForRowAtPoint: currentTouchPosition];
// NSLog(@"indexPath=%@",indexPath);
if (indexPath.row != 0)
{
NSBubbleData *data = [[self.bubbleSection objectAtIndex:indexPath.section] objectAtIndex:indexPath.row - 1];
[self.bubbleDataSource didSelectNSBubbleDataCell:data];
}


}
#pragma mark - Public interface

- (void) scrollBubbleViewToBottomAnimated:(BOOL)animated
Expand Down
2 changes: 1 addition & 1 deletion src/UIBubbleTableViewDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@

- (NSInteger)rowsForBubbleTable:(UIBubbleTableView *)tableView;
- (NSBubbleData *)bubbleTableView:(UIBubbleTableView *)tableView dataForRow:(NSInteger)row;

- (void)didSelectNSBubbleDataCell:(NSBubbleData *)dataCell;
@end