我可以在TabBarViewController(iOS 9.0 +)中使用SplitViewController吗?

时间:2016-08-10 07:02:44

标签: ios objective-c uitabbarcontroller uisplitviewcontroller

我有一个以UITabbarViewController为rootviewcontroller的应用。在某个标签项上,我希望在UISplitViewController内部有一个SplitViewController。 所以这里我的<?php $startLocation = "40.713,-74.0135"; $endLocation = "40.75773,-73.985708"; $waypoints = array("40.748433,-73.985656|", "40.689167,-74.044444|"); $apiKey = ""; $routeData = json_decode(file_get_contents("https://maps.googleapis.com/maps/api/directions/json?origin=".$startLoc."&destination=".$endLoc."&waypoints=optimize:true|".$waypoints."&key=".$apiKey)); echo "var waypointsOrder = ". json_encode($routeData->routes[0]->waypoint_order) . ";\n"; ?> var startLocation = {lat: 40.713, lng: -74.0135}; var endLocation = {lat: 40.75773, lng: -73.985708}; //get directions from the origin to the first waypoint var request = { origin: startLocation, destination: JSON.parse(places[waypointsOrder[0]][1]), travelMode: google.maps.TravelMode.DRIVING }; directionsService.route(request, function (result, status) { if (status == google.maps.DirectionsStatus.OK) { renderDirections(result, map); } }); //get directions from the last waypoint to the destination var request = { origin: JSON.parse(places[waypointsOrder[waypointsOrder.length-1]][1]), destination: endLocation, travelMode: google.maps.TravelMode.DRIVING }; directionsService.route(request, function (result, status) { if (status == google.maps.DirectionsStatus.OK) { renderDirections(result, map); } }); //get directions between each waypoint for (i = 1; i < waypointsOrder.length; i++) { var request = { origin: JSON.parse(places[waypointsOrder[i-1]][1]), destination: JSON.parse(places[waypointsOrder[i]][1]), travelMode: google.maps.TravelMode.DRIVING }; directionsService.route(request, function (result, status) { if (status == google.maps.DirectionsStatus.OK) { renderDirections(result, map); } }); } function renderDirections(result, map) { var directionsDisplay = new google.maps.DirectionsRenderer ({ map: map }); directionsDisplay.setMap(map); directionsDisplay.setDirections(result); } 将成为TabbarVC的childViewController。

这会被允许吗?是否有任何Apple指南建议不要这样做?

正如我所见,他们建议将SplitVC作为RootVC。但是许多应用程序已经完成了我们现在正在做的事情。

2 个答案:

答案 0 :(得分:0)

Answers here might帮助Apple建议UISplitViewController应该始终是rootviewcontroller

我在视图控制器中创建UISplitViewController的情况几乎相同。所以我创建了自己的自定义SplitViewController

以下是苹果的说明

  

您无法将拆分视图控制器推送到导航堆栈。虽然可以在某些其他容器视图控制器中将拆分视图控制器安装为子级,但在大多数情况下不建议这样做。拆分视图控制器通常安装在应用程序窗口的根目录下。

答案 1 :(得分:0)

Apple HIG建议将标签栏作为根或将拆分视图控制器作为根。但是我仍然通过为标签栏的子视图控制器之一放置一个容器来实现这一点。这样一来,您就可以将拆分视图控制器加载到任何视图控制器的容器视图中,而不管其选项卡栏还是普通视图控制器。