AlexBarinov / UIBubbleTableView

Cocoa UI component for chat bubbles with avatars and images support
http://alexbarinov.github.com/UIBubbleTableView/
842 stars 232 forks source link

Catch didSelectRowAtIndexPath in ControllerView? #66

Open menasheu opened 10 years ago

menasheu commented 10 years ago

if I want to implement a didSelectRowAtIndexPath (to push a new View when a user selects a bubble) in UIBubbleTableView, how would you suggest to catch the event in ControllerView

eliburke commented 10 years ago

You might want to use this fork, which is more up-to-date: https://github.com/huffpostlabs/HPLChatViewController/

If you set your ControllerView to be the table's delegate, then you can implement didSelectRowAtIndexPath in the ControllerView.

Or, you could use a gesture recognizer:

// in viewDidLoad
_tapRecognizer = [UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onListTap:)];
[_chatTable addGestureRecognizer _tapRecognizer];

and

- (void)onListTap:(UIGestureRecognizer*)recognizer {
    if (recognizer.state == UIGestureRecognizerStateEnded) {
        CGPoint tapLocation = [recognizer locationInView:_chatTable];
        NSIndexPath *tapIndexPath = [_chatTable indexPathForRowAtPoint:tapLocation];
        UIBubbleTableViewCell * cell = (UIBubbleTableViewCell*) [_chatTable cellForRowAtIndexPath:tapIndexPath];
        // create new view here
    }
}
menasheu commented 10 years ago

Thanks a lot. The Table delegate looks a good solution, but I will try both.

From: eliburke [mailto:notifications@github.com] Sent: Thursday, January 16, 2014 3:46 PM To: AlexBarinov/UIBubbleTableView Cc: menasheu Subject: Re: [UIBubbleTableView] Catch didSelectRowAtIndexPath in ControllerView? (#66)

You might want to use this fork, which is more up-to-date: https://github.com/huffpostlabs/HPLChatViewController/

If you set your ControllerView to be the table's delegate, then you can implement didSelectRowAtIndexPath in the ControllerView.

Or, you could use a gesture recognizer:

// in viewDidLoad _tapRecognizer = [UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onListTap:)]; [_chatTable addGestureRecognizer _tapRecognizer];

and

— Reply to this email directly or view it on GitHub https://github.com/AlexBarinov/UIBubbleTableView/issues/66#issuecomment-32469503 . https://github.com/notifications/beacon/3194837__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNTQxMjc3MSwiZGF0YSI6eyJpZCI6MjM2MzM4NTN9fQ==--020c90bd4b6fabcc3fd4723a951159fb9542d1b4.gif

menasheu commented 10 years ago

The strange thing is that once I did:

[bubbleTable setDelegate:self] in the viewDidLoad of ViewController.m (and added ,UITableViewDelegate> in ViewController.h),

all the images were cut to the have the height of the text part of the bubble.

Do you have an idea why this happened?

From: eliburke [mailto:notifications@github.com] Sent: Thursday, January 16, 2014 3:46 PM To: AlexBarinov/UIBubbleTableView Cc: menasheu Subject: Re: [UIBubbleTableView] Catch didSelectRowAtIndexPath in ControllerView? (#66)

You might want to use this fork, which is more up-to-date: https://github.com/huffpostlabs/HPLChatViewController/

If you set your ControllerView to be the table's delegate, then you can implement didSelectRowAtIndexPath in the ControllerView.

Or, you could use a gesture recognizer:

// in viewDidLoad _tapRecognizer = [UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onListTap:)]; [_chatTable addGestureRecognizer _tapRecognizer];

and

— Reply to this email directly or view it on GitHub https://github.com/AlexBarinov/UIBubbleTableView/issues/66#issuecomment-32469503 . https://github.com/notifications/beacon/3194837__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNTQxMjc3MSwiZGF0YSI6eyJpZCI6MjM2MzM4NTN9fQ==--020c90bd4b6fabcc3fd4723a951159fb9542d1b4.gif

eliburke commented 10 years ago

It's been a while since I worked with the stock code, but you might take a look at heightForRowAtIndexPath in UIBubbleTableView to make sure it has the correct size of your image. If that fails, try setupInternalData in UIBubbleTableViewCell