2012-08-06 65 views
1

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

代码: -

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]; 


} 
+0

它没有显示该视图第一次出现。它,当我点击它again.That装置WEPopover控制器未示出第一时间正确吗? – Nikunj 2012-08-06 14:24:15

+0

没有显示WEPopover,但是它不是第一次加载viewController。如果你知道,那么请告诉我解决方案 – 2012-08-06 14:35:01

回答

2

else部分尝试用这个小变化,因为我用这样的方式可能会有所帮助,它工作正常。

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

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