AlexBarinov/UIBubbleTableView

Catch didSelectRowAtIndexPath in ControllerView?

menasheu opened this issue · 4 comments

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

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

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

  • (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
    }
    }


Reply to this email directly or view it on GitHub #66 (comment) . https://github.com/notifications/beacon/3194837__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNTQxMjc3MSwiZGF0YSI6eyJpZCI6MjM2MzM4NTN9fQ==--020c90bd4b6fabcc3fd4723a951159fb9542d1b4.gif

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

  • (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
    }
    }


Reply to this email directly or view it on GitHub #66 (comment) . https://github.com/notifications/beacon/3194837__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNTQxMjc3MSwiZGF0YSI6eyJpZCI6MjM2MzM4NTN9fQ==--020c90bd4b6fabcc3fd4723a951159fb9542d1b4.gif

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