Open NickIliev opened 8 years ago
Hey @alexrainman
Here you can find a POC application that shows how to run NativeScript for iOS in Apple TV. The application is extending UIPageViewController with the marshalling techniques used in NativeScript for data conversion.
The example is in JS but you can follow the guides for runtime references in the documentation (with installing tns-platform-declarations for enabling TS for the native APIs)
From @alexrainman on October 11, 2016 15:40
@nickIliev i already saw that example but i cannot make it work, i get an exception:
-[UIPageViewController] Unrecognized selector sent to instance
Basically what im trying to do is to migrate my carousel view plugin for Xamarin Forms to Nativescript. Android is completed and its working like a charm but i cannot make iOS to work.
Maybe i can share a repo with you guys and you can take a look at my iOS code and find out what im doing wrong.
I am sure you will like what i am doing here and the community will love it.
Thanks in advance.
From @bradmartin on October 11, 2016 23:38
@alexrainman looking forward to seeing this. You at this point https://github.com/alexrainman/CarouselView/blob/master/CarouselView/CarouselView.FormsPlugin.iOS/CarouselViewImplementation.cs#L48 ?
From @alexrainman on October 11, 2016 23:43
@bradmartin i already wrote the whole thing. Android is working but i dont know what im doing wrong in iOS. Im following the documentation without luck. I implemented really cool stuff like TemplateSelector, Remove and Insert pages. As i said, android is ready for the first release.
From @alexrainman on October 11, 2016 23:45
@bradmartin im going to create a repo and share with you guys so i can get some help identifying what im doing wrong in iOS.
From @alexrainman on October 12, 2016 2:34
@bradmartin @NickIliev i created a private repo and invited you guys. I am sorry i uploaded everything, haven't time to remove packages and platforms. Please, take a look at carousel-view.ios.ts and let me know what i am doing wrong. I have one implementation using same style i have in my Xamarin.Forms version and another one "commented" that extends from UIPageViewController and implements DataSource and Delegate in one class.
If we can make it work, i will release version one with a good tutorial on how to use it and in my roadmap i will include vertical scrolling/swiping and page indicators.
Thanks in advance.
From @bradmartin on October 12, 2016 2:48
@alexrainman - couple other devs who might have the solution MUUUUCH faster than I could. @NathanaelA , @TheOriginalJosh , @NathanWalker, @sean-perkins . All very active with NativeScript and owners of many plugins. My iOS knowledge is minimal to be honest 😄 .
From @alexrainman on October 12, 2016 2:58
@bradmartin will invite them. Thanks
ping @jasssonpet, @ivanbuhov , @KristinaKoeva
Hey @alexrainman,
Can you tell us what's the name of the unrecognized selector that is being sent. It should be in the application logs.
@jasssonpet this is what i get
Oct 12 09:07:17 Alexs-MacBook-Pro CarouselView[72188]: assertion failed: 16A323 14A345: libxpc.dylib + 62597 [37A9DF49-35C1-3D93-B854-B35CACF0100F]: 0x7d
Oct 12 09:07:17 Alexs-MacBook-Pro CarouselView[72188]: CONSOLE WARN file:///app/carousel-view/carousel-view.js:271:14: The TypeScript constructor "ViewContainer" will not be executed.
Oct 12 09:07:17 Alexs-MacBook-Pro CarouselView[72188]: -[UIPageViewController superview]: unrecognized selector sent to instance 0x7fbf9085e000
Oct 12 09:07:17 Alexs-MacBook-Pro com.apple.CoreSimulator.SimDevice.494AA4EA-8C5B-41F7-82A0-C0E42391B052.launchd_sim[35217] (UIKitApplication:org.nativescript.CarouselViewDemo[0x87c9][72188]): Service exited due to Segmentation fault: 11
@alexrainman: superview
is a method on UIView
, not UIViewController
- you need something like aController.view.superview
.
Additionally you can generate TypeScript declarations to resolve such issues.
@jasssonpet also, in Android i am using this to convert N view to Android view:
var view = this._owner.templateSelector.OnSelectTemplate(position, item);
var obj = <any>view;
obj._onAttached(application.android.currentContext);
but obj._onAttached() doesn't works in iOS. Native view is null.
I am surprised. When i was developing this for Xamarin.Forms, Android version was really difficult to do. I was sure that iOS was piece of cake, i was wrong :)
@fealebenpae basically im trying to reproduce here what i did before. The plugin is extending Nativescript View, so i return ViewGroup in Android and i believe i should return UIView in iOS, that's what i did in my Xamarin.Forms version. If i do that with nativescript, at leats i see a white screen :)
If i follow other UI plugins practices, returning UIPageViewController itself, it crash on startup.
UIPageViewController children are UIViewController, so i create and empty UIViewController, i assign the view at index as it's main view and then i add the ViewController to UIPageViewController. That's what i did in Xamarin and that's what you do in pure obj-c or swift, but it doesn't works here.
Does the tvOS sample work if you paste it verbatim?
It sounds as if you're passing a UIPageViewController
instance to a native method that expects an UIView
, given how it tries to call the superview
method on said UIPageViewController
, which is defined on UIView
. I would suggest double-checking your datatypes and consulting the docs for the native APIs you call to make sure the types of arguments you pass to the native API are the same as the ones it expects.
I tried everything without luck, any help?
From @alexrainman on October 10, 2016 22:39
Can anyone provide a TS example using this widget?
Copied from original issue: NativeScript/NativeScript#2874