2014-09-13 86 views
1

我有一個UIPopovercontroller。 使用這種方式呈現它。iOS8 popovercontroller高度問題

BackupPop *backupPop = [[BackupPop alloc] initWithNibName:nil bundle:[NSBundle mainBundle]]; 
backupPop.delegate = self; 

backupPop.navigationItem.title = [Language get2:@"Backup"]; 
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:backupPop]; 
assigningBackupRow = button.tag; 
backupPopController = [[UIPopoverController alloc] initWithContentViewController:navController]; 
backupPopController.popoverContentSize = CGSizeMake(200, 150); 
CGRect rect = CGRectMake(button.frame.origin.x, button.frame.origin.y + 20 + (button.tag - 30000) * 44, button.frame.size.width, button.frame.size.height); 
[backupPopController presentPopoverFromRect:rect inView:backupTable permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES]; 

在UIPopovercontroller中,我在viewdidload中有一個UITableView。

funcTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 200, 80) style:UITableViewStylePlain]; 
[funcTable setDelegate:self]; 
[funcTable setDataSource:self]; 
[funcTable setRowHeight:44]; 
[funcTable setBackgroundColor:[UIColor clearColor]]; 
[self.view addSubview:funcTable]; 

在iOS8上的問題,雖然我的UITableView在高度80px,它顯示爲只有40像素。 UITableView的起始位置是正確的,但高度不是。現在,我必須將120px放置到UIPopoverController中的所有UITableView。 iOS7中沒有這樣的問題。 夥計們,有什麼想法?謝謝。

回答

0

我有同樣的問題。我所做的是在我展示我的popover之前,我明確地設置了tableview的大小。

[backupPop adjustFrame]; 
backupPopController.popoverContentSize = backupPop.view.frame.size; 
[backupPopController presentPopoverFromRect:rect inView:backupTable permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES]; 

,您可以在backupPop

- (void)adjustFrame { 
    CGRect frame = self.view.frame; 
    frame.size.height = 80 
    frame.size.width = 200; 
    self.view.frame = frame; 
} 

還是讓我知道這是否有助於增加一個方法。

+0

嘿感謝您的幫助,但它似乎並不奏效。 – user774150 2014-09-17 14:20:14

0

可能是其解決方法設置內容大小後一點點延遲。

dispatch_after({[:動畫CGSizeMake(300,340):self.popoverController setPopoverContentSize YES] ; } dispatch_time(DISPATCH_TIME_NOW,(的int64_t)(0.01 * NSEC_PER_SEC)),dispatch_get_main_queue(),^);

1

嘗試此

的iOS 8具有稱爲UIPopoverPresentationController新PopOverController

UIStoryboard *故事板= [UIStoryboard storyboardWithName:@ 「主」 束:無]; UINavigationController * navController = [storyboard instantiateViewControllerWithIdentifier:@「Terms_NC」];

navController.preferredContentSize = CGSizeMake(300, 290); 

// Present the view controller using the popover style. 
navController.modalPresentationStyle = UIModalPresentationPopover; 
[self presentViewController:navController animated: YES completion: nil]; 

// Get the popover presentation controller and configure it. 
UIPopoverPresentationController *presentationController = 
[navController popoverPresentationController]; 
presentationController.permittedArrowDirections =0; 
presentationController.sourceView = self.view; 
presentationController.sourceRect = CGRectMake(100, 100, 300, 340);