We help IT Professionals succeed at work.

UIMenuController's copy bubble problem

hey, currently I have a small problem with UIMenuController's copy bubble.

My set up is that I have a TableView, and inside the TableView I have bunch of TableViewCells.
Inside each TableViewCells I have a image called balloonView
And I say show me the UIMenuController's menu in the rect which is balloonView's frame(this frame is with respect to the TableViewCell, not with respect to the window.
The problem is whichever row I tap on the table, it will show the copyMenu on same place in the window. I think it is because position of "rect"is with respect to the TableViewCell.
But what I want is that when I tap image of row X, it will show that copy menu on top of the row which i selected. How can I do that?
cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
		balloonView = (UIImageView *)[[cell.contentView viewWithTag:kMessage] viewWithTag:kBallonView];
		rect = [balloonView frame];
		UIMenuController *copyMenu = [UIMenuController sharedMenuController];
		[copyMenu setTargetRect:rect inView:cell.contentView];
		[copyMenu setMenuVisible:YES animated:YES];

Open in new window

Watch Question

It's very difficult to understand - table view, cells, balloons. :) No screenshot at all.
The code looks correct. So, I think your right, and the question is about the rectangle. Or about the view. I think, it is here:
 [copyMenu setTargetRect:rectToPut inView:viewToPut];
Somehow I think there should be the 'self', or view or self.view :) or superview - I do not know where is this code in your app.

Seems like you know all at that posted here:
Check again, maybe, it will give you an idea.

Also check Listing 3-15  Displaying the editing menu here:

This code should work
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
[[balloonView superView] convertRect:rect toView:window];

Open in new window