我在我的應用程序中使用WEPopover彈出一個包含一些按鈕的彈出窗口控制器,它工作時,我把tabpopIteam中的wepopover控制器動作,但我需要得到彈出窗口,當我點擊UIButton.How做到這一點,這是我的barbuttonitem代碼顯示popover。從UIButton而不是UIBarButtonItem顯示WEPopover
-(IBAction)_clickbtnAccount:(id)sender
{
if (!self.popoverController)
{
UIViewController *contentViewController = [[pageAccount alloc]initWithNibName:@"pageAccount" bundle:nil];
self.popoverController = [[[popoverClass alloc] initWithContentViewController:contentViewController] autorelease];
self.popoverController.delegate = self;
self.popoverController.passthroughViews = [NSArray arrayWithObject:self.navigationController.navigationBar];
[self.popoverController presentPopoverFromBarButtonItem:sender
permittedArrowDirections:(UIPopoverArrowDirectionUp|UIPopoverArrowDirectionDown)
animated:YES];
[contentViewController release];
}
else
{
[self.popoverController dismissPopoverAnimated:YES];
self.popoverController = nil;
}
}
-(IBAction)_clickbtnAccount:(id)sender
{
if (!self.popoverController)
{
UIButton *senderButton = (UIButton *)sender;
[self.popoverController presentPopoverFromRect:[senderButton frame]
inView:@"pageAccount"
permittedArrowDirections:(UIPopoverArrowDirectionUp|UIPopoverArrowDirectionDown)
animated:YES];
}
else
{
[self.popoverController dismissPopoverAnimated:YES];
self.popoverController = nil;
}
}
感謝你的回答,但你能解釋我的按鈕的重量如何? – ICoder
剛剛編輯我的答案 - 希望現在更容易理解。 – tilo
- (IBAction爲)_clickbtnAccount:(ID)發送方 { \t如果(!self.popoverController){ \t \t \t \t \t \t的UIButton * senderButton =(的UIButton *)發送者; \t \t [self.popoverController presentPopoverFromRect:[senderButton幀] \t \t \t \t \t \t \t \t \t \t \t \t inView:@ 「pageAccount」 \t \t \t \t \t \t \t permittedArrowDirections:(UIPopoverArrowDirectionUp | UIPopoverArrowDirectionDown) \t \t \t \t \t \t \t \t \t \t \t animated:YES]; \t \t \t \t \t }否則{ \t \t [self.popoverController dismissPopoverAnimated:YES]; \t \t自我。popoverController = nil; \t} \t \t } – ICoder