2014-10-07 24 views
5

別人一樣來iOS8上,我收到了警告:呈現在分離視圖控制器...... - 有時

Presenting view controllers on detached view controllers is discouraged <EditItineraryViewController: 0x7ca56e00>. 

這是由下面的代碼引起的:

- (void)editActivityDetailsForIndexPath:(NSIndexPath *)indexPath { 
    NSPredicate *predicateForDisplay = [[NSPredicate alloc] init]; 
    switch (indexPath.section) { 
     case kIncompleteActivitiesSection: 
      predicateForDisplay = _predIncomplete; 
      break; 
     case kCompleteActivitiesSection: 
      predicateForDisplay = _predComplete; 
      break; 
     default: 
      break; 
    } 
    NSString *theActivityName = [[NSString alloc] init]; 
    theActivityName = [[[_activitiesArray filteredArrayUsingPredicate:predicateForDisplay] objectAtIndex:indexPath.row] activityName]; 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    ActivityDetailViewController *activityDetailVC = [storyboard instantiateViewControllerWithIdentifier:@"ActivityDetailView"]; 
    activityDetailVC.modalPresentationStyle = UIModalPresentationFormSheet; 
    activityDetailVC.delegate = self; 
    // send the activity to the view 
    activityDetailVC.theActivity = [[_activitiesArray filteredArrayUsingPredicate:predicateForDisplay] objectAtIndex:indexPath.row]; 
    // configure the look of the view 
    _activityDetailsPopover = [[UIPopoverController alloc] initWithContentViewController:activityDetailVC]; 
    _activityDetailsPopover.delegate = self; 
    ItineraryCell *cell = (ItineraryCell *)[self.itineraryTableView cellForRowAtIndexPath:indexPath]; 
    activityDetailVC.contentView.backgroundColor = [UIColor whiteColor]; 
    activityDetailVC.navigationBar.barTintColor = _colorSchemeLightColor; 
    activityDetailVC.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:_colorSchemeColor}; 
    activityDetailVC.saveButton.tintColor = _colorSchemeColor; 
    activityDetailVC.cancelButton.tintColor = _colorSchemeColor; 
    activityDetailVC.labelB.textColor = _colorSchemeColor; 
    activityDetailVC.labelM.textColor = _colorSchemeColor; 
    activityDetailVC.activityTitle.textColor = _colorSchemeColor; 
    activityDetailVC.activityTitle.font = [UIFont boldSystemFontOfSize:17.0]; 
    // present the view 
    [_activityDetailsPopover presentPopoverFromRect:cell.cellDetailsButton.frame inView:cell.cellDetailsButton.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
} 

這是一個iPad應用程序,在這種情況下,彈出窗口的顯示方式是讓它的小指針指向位於tableview單元格中的「i」圖標。

這在我的應用程序的另外三個地方工作,根本沒有引起警告。但是由於某種原因,在這個實現中,它引發了警告。奇怪的是,這是我的應用程序中的第一個地方,我用這種方式呈現來自tableview單元格的彈出窗口,其他實例僅僅是此代碼的副本!

任何想法,我可以看看,以找出層次結構被糾纏在哪裏?它與tableview單元格是如何生成的,然後將這個popover展現在它的頂部,還是它必須嚴格地與popover本身相關?或者它可能與tableview有關。我甚至不知道從哪裏開始尋找。

非常感謝!

+1

任何人都可以幫助我嗎? – Kent 2014-10-25 22:10:20

+0

你找到答案了嗎?我也有同樣的問題 – silvaric 2014-11-18 13:53:53

回答

2

我通過呈現來自呈現tableView的視圖控制器(在我的情況下集合視圖)的彈出窗口來解決此問題。當你從一個單元格出現問題時就會出現。 我假設任何單元格被視爲「獨立視圖控制器」,因此從他們呈現將給你這個錯誤,並不會收到旋轉事件,而這又不會使用popoverPresentationController:willRepositionPopoverToRect:inView:回調。

相關問題