5

Để thiết lập các cảnh tôi có:Hai UISplitViewControllers, 1 (Shared) chi tiết

  • Một Tab View Controller với 2 tab
  • Mỗi tab có Split View khiển
  • Tôi muốn trỏ chế độ xem Chi tiết của từng Bộ điều khiển Chế độ xem Chia tách đến chế độ xem CÙNG.

Tôi đã đính kèm một đơn giản sample project showing the issue.

Chạy ứng dụng trong iPad 5.1 Sim, quan sát từng tab. Một hiển thị chế độ xem chi tiết được chia sẻ, một chế độ xem không thành công.

NSLog gỡ lỗi báo cáo rằng quan điểm phân chia thứ hai có một bộ điều khiển NULL xem chi tiết:

 
2012-04-28 07:21:55.451 svcTest[14597:f803] tabBarController viewControllers = (
    "UISplitViewController: 0x6a36100", 
    "UISplitViewController: 0x6a39ab0" 
) 
2012-04-28 07:21:55.455 svcTest[14597:f803] svcA.viewControllers = (
    "UINavigationController: 0x6a36250", 
    "UIViewController: 0x6a38720" 
) 
2012-04-28 07:21:55.457 svcTest[14597:f803] svcB.viewControllers = (
    "UINavigationController: 0x6a39cc0" 
) 

Khi bạn nhấp vào tab thứ hai bạn nhận được lỗi này:

2012-04-28 07:22:58.457 svcTest[14597:f803] Splitview controller is expected to have a detail children before its used! 
2012-04-28 07:22:58.459 svcTest[14597:f803] Split view controller should have its children set before layout!

Nhìn vào kịch bản tôi có đã đặt chế độ xem chi tiết để điều này thực sự gây nhầm lẫn cho tôi.

Storyboard

Bất kỳ sự giúp đỡ nhận này xem 'chia sẻ' để hiển thị trên mỗi tab được nhiều đánh giá cao.

Cảm ơn!

Trả lời

1

Tôi nhận được cảnh báo tương tự khi quy định cụ thể hơn hai viewControllers cho splitViewController như hình dưới đây:

self.splitViewController.viewControllers = @[masterNavigationController, detailNavigationController, subViewController]; 

Khi tôi loại bỏ 'subViewController' từ mảng cảnh báo biến mất.

Sau khi đọc tài liệu hướng dẫn táo về thêm/gỡ bỏ subviews nó đề cập đến những điều sau đây:

The array in this property must contain exactly two view controllers. The view controllers are presented left-to-right in the split view interface when it is in a landscape orientation. Thus, the view controller at index 0 is displayed on the left side and the view controller at index 1 is displayed on the right side of the interface.

Bạn có thể kiểm tra các liên kết đến UISplitViewController Class Reference để biết thêm thông tin.

1

Vấn đề là ở vị trí của một số dòng nằm trong App Đại biểu của -applicationdidFinishLaunchingWithOptions:

Ở đây, sự chia rẽ quan điểm điều khiển đại biểu được thiết lập trước khi viewControllers. Điều này dường như là nguồn gốc của vấn đề và nếu bạn đảo ngược hai dòng như hình dưới đây các thông điệp cảnh báo sẽ biến mất:

Sử dụng Bộ luật này thay vì:

self.splitViewController = [[UISplitViewController alloc] init]; 
self.splitViewController.viewControllers = [NSArray 
          arrayWithObjects:masterNavigationController, 
          detailNavigationController, nil]; 
self.splitViewController.delegate = detailViewController; 

Đối với giải thích chi tiết, bạn có thể có một cái nhìn tại : Splitview Controller Is Expected to Have a Master View Controller

+0

Cảm ơn đề xuất của bạn. Tôi không thấy cảnh báo biến mất bằng cách di chuyển .delegate sau khi gán .viewControllers, nhưng trong trường hợp của tôi, tôi đã có thể sửa nó bằng cách di chuyển một số thuộc tính mà tôi đã thiết lập sau .viewControllers (đặc biệt là ưa thíchDisplayMode, preferredPrimaryColumnWidthFraction ...). Tôi đang viết về iOS 9.3. – ggould75