Есть ли способ представить UIPopover из индекса UITableView?

Я хотел бы представить UIPopover из специального индекса UITableView. Вот мой код:

if (indexPath.row == 5) {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    EnginesPopoverController  *enginesPopoverController = [[EnginesPopoverController alloc] initWithNibName:@"EnginesPopoverController" bundle:nil];

    UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:enginesPopoverController];

    self.popoverController = popover;
    popoverController.delegate = self;

    [popover release];
    [enginesPopoverController release];

    CGPoint point = {670, 600};
    CGSize size = {450, 216};

    [popoverController presentPopoverFromRect:CGRectMake(point.x, point.y, size.width, size.height) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];                 
}

Если я попытаюсь представить Popover из UIButton, все пойдет хорошо...

Спасибо!


person Community    schedule 30.07.2010    source источник
comment
В каком методе определен этот код?   -  person kennytm    schedule 30.07.2010
comment
- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath   -  person    schedule 30.07.2010


Ответы (2)


Вот что я делаю:

CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath]; 
CGRect popoverRect = CGRectMake(self.view.bounds.size.width - self.popoverController.popoverContentSize.width,
                                CGRectGetMidY(cellRect),
                                1.0, 1.0);

Место x, которое я использую, помещает всплывающее окно в правую часть экрана. Это может быть не то, что вы хотите. Чтобы найти фактическую точку касания, вы можете использовать распознаватели жестов.

В свою очередь, попробуйте ответить на мой связанный с этим вопрос: стрелка Popover на отслеживать объект в прокрутке

person David M.    schedule 09.08.2010

Манипулируя кодом Дэвида, я пришел к следующему: (мое всплывающее окно называется «storytPop») — мое всплывающее окно находится на панели инструментов, и я хотел, чтобы следующее табличное представление отображалось справа.

CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath]; 
[self.storytPop presentPopoverFromRect:cellRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
person anna    schedule 24.02.2011