WEPopover不起作用

时间:2012-08-06 13:46:47

标签: iphone uitouch

我在我的项目中使用WEPopover。我已经集成了它,它正在显示PopoverController。我作为contentViewController添加的类是UITableViewController的子类。我正在加载另一个视图控制器的didSelectRowAtIndexPath,但它没有第一次显示此视图。当我再次点击它时出现。我正在添加我的代码。请帮我解决这个问题。

UITouch上的代码: -

if([[touch view] isKindOfClass:[backGroundImageView class]] && numTaps ==1)

    { 

            CGPoint startLocation   = [touch locationInView:backGroundImageView];

             startX = startLocation.x;
             startY = startLocation.y;

        CGRect rect = CGRectMake(startX, startY, 300, 90); 



        if(self.popoverController)
        {

            [self.popoverController dismissPopoverAnimated:YES];
            self.popoverController = nil;

        }
        else
        {

        UIViewController *contentViewController = [[WEPopoverContentViewController alloc] initWithStyle:UITableViewStylePlain];


        self.popoverController = [[[popoverClass alloc] initWithContentViewController:contentViewController] autorelease];



        if ([self.popoverController respondsToSelector:@selector(setContainerViewProperties:)]) {
            [self.popoverController setContainerViewProperties:[self improvedContainerViewProperties]];
        }

        self.popoverController.delegate = self;

        //Uncomment the line below to allow the table view to handle events while the popover is displayed.
        //Otherwise the popover is dismissed automatically if a user touches anywhere outside of its view.

        self.popoverController.passthroughViews = [NSArray arrayWithObject:backGroundImageView];
        NSLog(@"rect1: %@", NSStringFromCGRect(rect));

        [self.popoverController presentPopoverFromRect:rect  
                                                inView:backGroundImageView 
                              permittedArrowDirections:(UIPopoverArrowDirectionUp|UIPopoverArrowDirectionDown|
                                                        UIPopoverArrowDirectionLeft|UIPopoverArrowDirectionRight)
                                              animated:YES];


}

1 个答案:

答案 0 :(得分:1)

else部分尝试这个小改动,可能会有所帮助因为我这样使用它并且工作正常。

self.popoverController = [[[WEPopoverContentViewController alloc] initWithContentViewController:yourAnotherViewController] autorelease];

假设self.popoverController是WEPopoverContentViewController的对象 假设已经分配了yourAnotherViewController