呈现在分离视图控制器...... - 有时

问题描述:

别人一样来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

我通过呈现来自呈现tableView的视图控制器(在我的情况下集合视图)的弹出窗口来解决此问题。当你从一个单元格出现问题时就会出现。 我假设任何单元格被视为“独立视图控制器”,因此从他们呈现将给你这个错误,并不会收到旋转事件,而这又不会使用popoverPresentationController:willRepositionPopoverToRect:inView:回调。