alexrainman / nativescript-carousel-view

CarouselView plugin for NativeScript
MIT License
16 stars 5 forks source link

Cannot make iOS version work #1

Closed alexrainman closed 7 years ago

alexrainman commented 7 years ago

Guys, basically this repo is work in progress. I am migrating my CarouselView for Xamarin.Forms to NativeScript.

I got Android version working and ready for release one but i am missing something in iOS. I get this exception:

-[UIPageViewController] Unrecognized selector sent to instance.

I know iOS pretty well but i am not NativeScript expert.

Please take a look at carousel-view.ios.ts file. I have two implementations. One based on my previous plugin for Xamarin and another one that inherits from UIPageViewController and implements DataSource and Delegate in one class.

If we can make this works then i can move forward.

Roadmap:

Thanks in advance.

bradmartin commented 7 years ago

I've looked at your code but nothing pops out to me, tried testing and have the same error. My iOS skills just aren't that great and I've spent time looking at the iOS docs for this but again... not much clicking, would take more time. Really hoping someone on the core team points you in the right direction. The Android version was solid when I ran the demo app 👍

alexrainman commented 7 years ago

@bradmartin thanks for expending some time on this. I also hope someone on the core team can tell me what im missing here. This is a must have plugin and i have big plans for it :)

alexrainman commented 7 years ago

@bradmartin @NickIliev just giving up on this :(

bradmartin commented 7 years ago

@nathanwalker is one of your best bets for help but the man's time is valuable 😄

alexrainman commented 7 years ago

@bradmartin i know but he never responded to the invite :)

alexrainman commented 7 years ago

@bradmartin @NickIliev i am really interested in pushing this plugin as it's a must have, to the company i work for, to decide if we switch from Xamarin to NativeScript.

NathanWalker commented 7 years ago

@alexrainman been working on this a.m. for ya. Got it running now. Should give you enough to develop it further. Bout to push it up.

alexrainman commented 7 years ago

@nathanwalker thats excelent news, thanks for expending your valuable time on this. Awesome :)

NathanWalker commented 7 years ago

This will make an awesome plugin, great work on it so far!

alexrainman commented 7 years ago

@nathanwalker thanks, i love to share with the community. Please leave me comments on what i was doing wrong

NathanWalker commented 7 years ago

Ok so just pushed up, basically I am extending ContentView which I always have better luck with when doing custom iOS ui components. Still more to figure out... go ahead and run it and take a look... We still need to figure out this: https://github.com/alexrainman/nativescript-carousel-view/blob/master/app/carousel-view/carousel-view.ios.ts#L18-L25

But that should get you much further.

NathanWalker commented 7 years ago

So it runs now and the proper methods are being called but we don't see the UIPageView in the view yet however things work. The comment on the line above is key to making it show up in the view.

NathanWalker commented 7 years ago

Also, you will be happy to know {N} helps you out with things like this: https://github.com/alexrainman/nativescript-carousel-view/blob/master/app/carousel-view/carousel-view.ios.ts#L116-L119

👍

alexrainman commented 7 years ago

@NathanWalker i will take a look and let you know how ti goes. Thanks a lot 👍

alexrainman commented 7 years ago

@NathanWalker i made this changes to match what i have in Xamarin and also change it back to the implementation with View and not ContentView (doesn't works on Android).

get ios(): UIView{
    return this._ios.view;
}

get _nativeView(): any {
    return this._ios.view;
}

And now we don't have -[UIPageViewController superview]: unrecognized selector sent to instance 0x7f9d21804000 issue.

alexrainman commented 7 years ago

Basically that was the missing part :)

Slides still white, i cannot swipe but i can move back and fort programmatically and also InsertPage works. I still get this warning:

The TypeScript constructor "ViewContainer" will not be executed.

I believe it's a view Frame issue.

alexrainman commented 7 years ago

@NathanWalker also onLoaded helped me to solve one issue.

public onLoaded() {

        let firstViewController = this.createViewController(this.position);
        let direction = UIPageViewControllerNavigationDirection.UIPageViewControllerNavigationDirectionForward;
        this._ios.setViewControllersDirectionAnimatedCompletion (<any>[firstViewController], direction, false, (arg1) => {});

        var eventData: observable.EventData = {
            eventName: "positionSelected",
            object: this
        }
        this.notify(eventData);
    }

Now this is working but i still getting white screen and i believe it's constraints issue so, i will implement some stuff using "visual format language" and see how that goes.

We are close :)

alexrainman commented 7 years ago

@NathanWalker i did some test and, the size of UIPageViewController and each controller i'm adding to it is correct but, the UIView seems to be empty or it's size is incorrect.

As you saw in my code i'm using this to convert N view to UIView.

var view = this.templateSelector.OnSelectTemplate(position, item);
var obj = <any>view;
obj._onAttached();
var viewController = new ViewContainer();
viewController.tag = position;
viewController.view = obj._view;

I also trie obj.ios without luck. I can see that obj._subViews contains the elements but somehow they don't show in screen.

bradmartin commented 7 years ago

What's the current XML for what you're trying?

alexrainman commented 7 years ago

I just uploaded the code for iOS, take a look. It's working but no UI. I am using same as Android. Stacklayout with 2 labels and a button.

bradmartin commented 7 years ago

Try attaching a loaded event to the CarouselView here: https://github.com/alexrainman/nativescript-carousel-view/blob/master/app/Views/main-page.xml#L9 and possibly hard coding the height and width to some value. Just some things I would try. In the loaded event (just FYI) the carouselLoaded(args) { args.view } args.view should give you the instance of the view.

alexrainman commented 7 years ago

No no, the CarouselView (UIPageViewController) size is ok, also the size of each controller UIView is ok. Only the size of the view i am attaching to each UIViewController seems to be wrong or, calling obj._onAttached doesn't do the same as Android.

bradmartin commented 7 years ago

Ooooh. Well damn. I might give it a spin later to see but being iOS I'm once again going to be a lost cause most likely 😄 .

alexrainman commented 7 years ago

We are really close :)

alexrainman commented 7 years ago

Also, DidFinishAnimating in the delegate is not getting called and it's needed. I use it in my Xamarin.Forms version.

alexrainman commented 7 years ago

@NathanWalker @bradmartin summarizing issues:

I guess we need N core team help here :)

alexrainman commented 7 years ago

@bradmartin @NathanWalker good news guys, i solved must of the issues. Now DataSource and Delegate works :)

Only this one to go:

Uploading my latest code now so you can take a look. We have swiping now :)

alexrainman commented 7 years ago

I learned some tricks from NativeScript UI core modules :)

alexrainman commented 7 years ago

@NathanWalker i see you are a guitar player, like myself :)

NathanWalker commented 7 years ago

Excellent on all above! Maybe one day a jam can happen ;)

hshristov commented 7 years ago

@alexrainman Are there any remaining issues?

alexrainman commented 7 years ago

@hshristov yes, this one https://github.com/NativeScript/NativeScript/issues/2928 and i will be ready to release version 1 :)

alexrainman commented 7 years ago

@hshristov this is stable code that im migrating from Xamarin.Forms carousel plugin. Vertical swiping and page indicators are in my roadmap.

NathanWalker commented 7 years ago

This works now ?????!!!!

alexrainman commented 7 years ago

Yes it does, releasing version 1.0 soon :)

NathanWalker commented 7 years ago

@alexrainman woo hoo!!! nice work!!! 💯

bradmartin commented 7 years ago

Nice. Looking forward to it.

On Tue, Oct 25, 2016, 7:58 PM Alex Rainman notifications@github.com wrote:

Yes it does, releasing version 1.0 soon :)

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/alexrainman/nativescript-carousel-view/issues/1#issuecomment-256221375, or mute the thread https://github.com/notifications/unsubscribe-auth/AFulhN4CDUMgvk1GehCFLe14LYYitGpPks5q3qWdgaJpZM4KUU9a .

bradmartin commented 7 years ago

If you need help publishing to npm let us know 😄

alexrainman commented 7 years ago

I think i got it, but i hope you write a good article about it and i also hope to see it as a verified plugin :)

bradmartin commented 7 years ago

You'll have to get in touch with the NS team on verifying it, think that requires tests for the plugin. Also the plugin stuff might be getting an overhaul soon to be more like xamarin (ratings and other metrics). You might want to join the NativeScript slack channel to get in touch with the right people a little easier, email works though for some 😄

alexrainman commented 7 years ago

@bradmartin done https://www.npmjs.com/package/nativescript-carousel-view :)

bradmartin commented 7 years ago

@alexrainman Where is the repo for the actual plugin 😄 ? I'm slightly confused. I looked at the package.json after installing the plugin from npm and I believe that's the xamarin repo. So did you publish from this repo in the plugin folder and keep the package.json locally off the repo for the plugin? I want to contribute and help but not sure with the current setup.

bradmartin commented 7 years ago

K, I see the url clearly now 😄 so it is this repo

alexrainman commented 7 years ago

Yes, i just mentioned that its a port of my Xamarin plugin :)

bradmartin commented 7 years ago

I think it might be a good idea to move the actual plugin source out of the demo app, so it's easier for contributors to find. I say this because most plugins have followed a good structure from the beginning making it easier for NS devs to figure out. Any of mine or @NathanWalker repo's are setup with this approach, I used his seed project for most of my plugins so it was simple to get setup. No worries if you don't wanna go through the hassle, totally understand 👍 this is great regardless. Very nice work and about to use it in a project.

NathanWalker commented 7 years ago

@alexrainman this is fantastic, can't wait to use this in an app soon!

alexrainman commented 7 years ago

Thanks guys!

alexrainman commented 7 years ago

@bradmartin @NathanWalker @hshristov @tzraikov @NickIliev take a look on how much the plugin has evolved since i started working on it 👍

bradmartin commented 7 years ago

I seen the bump earlier. You're doing awesome man

On Thu, Dec 22, 2016, 3:09 PM Alex Rainman notifications@github.com wrote:

@bradmartin https://github.com/bradmartin @NathanWalker https://github.com/NathanWalker @hshristov https://github.com/hshristov @tzraikov https://github.com/tzraikov @NickIliev https://github.com/NickIliev take a look on how much the plugin has evolved since i started working on it 👍

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/alexrainman/nativescript-carousel-view/issues/1#issuecomment-268891136, or mute the thread https://github.com/notifications/unsubscribe-auth/AFulhNeX-SbRD2LidxpEe51Um3HkCE3aks5rKucngaJpZM4KUU9a .