我正在努力實現對CarPlay音頻應用程序的支持,並試圖在模擬器中顯示列表。我實施了MPPlayableContentDataSource
,但發現它被稱爲不一致。這是第一次在模擬器上啓動應用程序,並且如果CarPlay在啓動時打開,我可以通過滾動一個空的列表來觸發重繪來顯示第一個項目。 CarPlay似乎無法調用數據源,但是,在後續的啓動中,我看到一個空白屏幕或一個微調框,後面跟着消息Unable to connect to "AppName"
。我曾嘗試不同的東西,但主要觀點如下:MPPlayableContentDataSource調用不一致
在application: didFinishLaunchingWithOptions:
self.contentDataSource = [[MYContentDataSource alloc] init];
self.contentDelegate = [[MYContentDelegate alloc] init];
MPPlayableContentManager *contentManager = [MPPlayableContentManager sharedContentManager];
contentManager.dataSource = self.contentDataSource;
contentManager.delegate = self.contentDelegate;
[contentManager beginUpdates];
[contentManager endUpdates];
我與內容管理的beginUpdates
endUpdates
和reloadData
方法玩耍了,但這些結果中的內容數據源實際上被調用。
我已經在數據源中實現了numberOfChildItemsAtIndexPath
和contentItemAtIndexPath
,這似乎是正確調用的,只是在新的模擬器上首次啓動應用程序。
要點:
- (NSInteger)numberOfChildItemsAtIndexPath:(NSIndexPath *)indexPath {
return 3;
}
- (MPContentItem *)contentItemAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger categoryId = [indexPath indexAtPosition:0];
MPContentItem *contentItem = [[MPContentItem alloc] initWithIdentifier:[NSString stringWithFormat:@"CAT-%lu", (unsigned long)categoryId]];
contentItem.title = [NSString stringWithFormat:@"Category %lu", (unsigned long)categoryId];
contentItem.subtitle = @"Subtitle";
contentItem.playable = NO;
contentItem.container = YES;
}
我也試着保持(或沒有)的參考MPPlayableContentManager
。
我在實際的頭部單位上有相同的行爲。任何幫助,將不勝感激。
請在https://bugreport.apple.com上提交錯誤報告。附上您的項目(或一個示例項目)。重現問題,當模擬器仍然啓動時運行'xcrun simctl diagnose',然後將輸出附加到錯誤報告。 – russbishop
感謝您的注意 - 我能夠在實際的頭部單元上重現行爲,所以它不是一個模擬器錯誤 - 大概是我的代碼中的某個錯誤。我會嘗試構建一個示例項目來確認,如果它沒有重新生成,則會提交一個錯誤。現在正在處理另一個項目,但應該儘快回覆。 – Tad
如果您仍然需要幫助,我會很感興趣,我有CarPlay的經驗。請伸出手。 –