开发者

iPad use touches to display popover?

开发者 https://www.devze.com 2023-01-16 12:06 出处:网络
So I have been searching everywhere for a solution to this problem.I have a table view that displays a popover from a cell when the user selects it.However there is a bug but I can\'t figure out a sol

So I have been searching everywhere for a solution to this problem. I have a table view that displays a popover from a cell when the user selects it. However there is a bug but I can't figure out a solution. Basically once you scroll down off the first page of results, the popover always appears from the bottom of the screen instead of the selected table cell. The reason for this is I am creating the popover from the cell rectangle via:

CGRect cellRect = [tableView rectForRowAtIndexPath:indexPath];

self.detailController.contentSizeForViewInPopover = CGSizeMake(cellRect.size.width, 350);   
self.personDetailPopoverController = [[[UIPopoverController alloc] initWithContentViewController:self.detailController] autorelease];

[self.personDetailPopoverController presentPopoverFromRect:cellRect
                                        inView:self.view
                      permittedArrowDirections:UIPopoverArrowDirectionAny
                                      animated:YES];

This works great for the first 8 rows (my cells are 100 units tall), but causes that problem noted above because it is trying to display it at y=1400 (for the 14th cell, etc). Does anyone know of a better way to display t开发者_开发百科he popover from the selected cell? Perhaps a creative use of touches? Any feedback would be greatly appreciated. Thanks!


You need to convert your rectangle to your view's coordinate system:

[self.view convertRect:cellRect fromView:tableView];
0

精彩评论

暂无评论...
验证码 换一张
取 消