Skip to content
This repository has been archived by the owner on Mar 9, 2018. It is now read-only.

Catch didSelectRowAtIndexPath in ControllerView? #66

Open
menasheu opened this issue Jan 16, 2014 · 4 comments
Open

Catch didSelectRowAtIndexPath in ControllerView? #66

menasheu opened this issue Jan 16, 2014 · 4 comments

Comments

@menasheu
Copy link

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
Copy link

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
Copy link
Author

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

@menasheu
Copy link
Author

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

@eliburke
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants