1

As the question says,I want to get the position of a uibutton as shown in the image and I have to show a pop up menu from that uibutton(in the tableviews view).

I went through Question1 and Question2.But these are giving me different locations.

I use the code

    CGRect windowRect = [_tableView convertRect:button.frame fromView:tempCell];

temp cell is my selected cell.

I am using kxMenu for popUp menu,and I use the following code.

[KxMenu showMenuInView:_tableView
              fromRect:windowRect
             menuItems:menuItems];

So,I need to get the windowRect correctly.Anybody have any idea?

enter image description here

enter image description here

Community
  • 1
  • 1
abhimuralidharan
  • 5,452
  • 4
  • 44
  • 68
  • What did you use the method in Question 1 you linked? It looks like it should help you when used like this : `CGRect windowRect = [button convertRect:button.bounds toView:nil];` – Losiowaty Nov 25 '15 at 11:16
  • i use this code to get and seems correct `CGPoint windowPoint = [button convertPoint:button.bounds.origin toView:self.view];` (using this in scrollview) – Tj3n Nov 25 '15 at 11:21

1 Answers1

2

If you use

 [_tableView convertRect:button.frame fromView:tempCell];

It will convert frame of the button wrt tempcell to button frame wrt _tableView

If you want to get the frame of button wrt the window, you should do either

 [button convertRect:button.bounds toView:nil];

or

 [button.superView convertRect:button.frame toView:nil];
Johnykutty
  • 11,106
  • 11
  • 55
  • 95