Ken*_*ent 5 objective-c uitableview uiviewcontroller uipopover ios8
像其他人来到iOS8,我收到警告:
Presenting view controllers on detached view controllers is discouraged <EditItineraryViewController: 0x7ca56e00>.
Run Code Online (Sandbox Code Playgroud)
这是由以下代码引起的:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
这是一个iPad应用程序,在这种情况下,弹出窗口的呈现方式是让它的小指针指向位于tableview中的tableview单元格上的"i"图标.
这可以在我的应用程序中的其他三个位置工作,而不会引起警告.但出于某种原因,通过这种实现,它会引发警告.奇怪的是,这是我的应用程序中的第一个地方,我使用这种方式从tableview单元格呈现弹出窗口,其他实例只是此代码的副本!
我可以看到什么想法,以找出层次结构被错误的地方?它与tableview单元格的生成方式有关,然后在其上面显示此弹出窗口,还是必须严格执行popover本身?或者它可能与tableview有关.我甚至不知道从哪里开始看.
非常感谢!
我通过从呈现 tableView (在我的例子中是集合视图)的视图控制器中呈现弹出窗口来解决这个问题。当你从细胞中呈现时,问题就出现了。我假设任何单元格都被视为“分离的视图控制器”,因此从它们呈现会给您带来此错误,并且不会接收旋转事件,而旋转事件又不会使用回调popoverPresentationController:willRepositionPopoverToRect:inView:。
| 归档时间: |
|
| 查看次数: |
1740 次 |
| 最近记录: |