2012-08-06 23 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分配