objective c - Adding a CarPlay UI -


i working on current iphone audio app supported in carplay. got approved apple , received development entitlement, , watched video "enabling app carplay"(https://developer.apple.com/videos/play/wwdc2017/719/). in video there piece of swift code demonstrating how add carplay ui:

func updatecarwindow()   {       guard let screen = uiscreen.screens.first(where:      { $0.traitcollection.userinterfaceidiom == .carplay })       else       {           // carplay not connected           self.carwindow = nil;           return       }        // carplay connected       let carwindow = uiwindow(frame: screen.bounds)       carwindow.screen = screen       carwindow.makekeyandvisible()       carwindow.rootviewcontroller = carviewcontroller(nibname: nil, bundle: nil)       self.carwindow = carwindow } 

i re-wrote objective-c version following:

- (void) updatecarwindow   {       nsarray *screenarray = [uiscreen screens];        (uiscreen *screen in screenarray)       {                 if (screen.traitcollection.userinterfaceidiom == uiuserinterfaceidiomcarplay)  // carplay connected.         {               // screen's bounds can create window of correct size.               cgrect screenbounds = screen.bounds;                uiwindow *tempcarwindow = [[uiwindow alloc] initwithframe:screenbounds];               self.carwindow.screen = screen;               [self.carwindow makekeyandvisible];                // set initial ui window.               uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil];               uiviewcontroller *rootviewcontroller = [storyboard instantiateviewcontrollerwithidentifier:@"vc"];                self.carwindow.rootviewcontroller = rootviewcontroller;               self.carwindow = tempcarwindow;                // show window.               self.carwindow.hidden = no;               return;          }       }       // carplay not connected.     self.carwindow = nil;  }   

however found property "screens" of uiscreen return 1 element (the main screen), no matter when testing on real device or simulator. when app running on simulator or real car carplay system, app blank , said "unable connect "my app name"" (see image below). viewcontroller has simple uilabel though.

enter image description here

my question is: should make app connected carplay? is, how should obtain screen has uiuserinterfaceidiomcarplay idiom, not main screen? lot in advance.

carplay audio apps controlled mpplayablecontentmanager. required implement mpplayablecontentdelegate , mpplayablecontentdatasource protocol in order connect carplay. ui controlled carplay - need feed data tabs+tables (datasource) , respond playable items (delegate).


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -