Open hktari opened 6 years ago
Thanks @hktari Apparently, range slider ios package is not compatible with new iOS projects. I will try to fix it asap.
Hello @halkar! Did you find a solution? I'm still digging around source to fix this and use the range slider on my new iOS project :)
I got this exception:
Loaded assembly: /.........../Xamarin.RangeSlider.Common.dll [External] Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
But from source code, Xamarin.RangeSlider.Common.dll doesn't contain anything, just an enum type.
I compiled the source code with samples, and it works....
the latest nuget version, is the same of the actual source code??
I just noticed that on iOS sample, inside the main.cs you put:
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, "AppDelegate");
var t = typeof(RangeSliderRenderer); // <---- This line!!!!
}
}
Ok, I found a strange issue: I have to add Xamarin.RangeSlider nuget package too. I added only Xamarin.Forms.RangeSlider. (but this is enough for Droid and UWP)
Now, I got the same exception, but with more detials:
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
[0:] Eccezione non gestita: MonoTouch - System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.RangeSlider.RangeSliderControl.get_LowerHandleImageNormal () [0x00096] in <394d04d792de4791b21e337580082f54>:0
at Xamarin.RangeSlider.RangeSliderControl.get_IntrinsicContentSize () [0x0000a] in <394d04d792de4791b21e337580082f54>:0
at Xamarin.RangeSlider.RangeSliderControl.AddSubviews () [0x00010] in <394d04d792de4791b21e337580082f54>:0
at Xamarin.RangeSlider.RangeSliderControl.ConfigureView () [0x000de] in <394d04d792de4791b21e337580082f54>:0
at Xamarin.RangeSlider.RangeSliderControl..ctor (CoreGraphics.CGRect frame) [0x0001d] in <394d04d792de4791b21e337580082f54>:0
at Xamarin.RangeSlider.Forms.RangeSliderRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x0001e] in <521f210d41874847a6d12b7429bff1d6>:0 at Xamarin.Forms.Platform.iOS.VisualElementRenderer
1[TElement].SetElement (TElement element) [0x00118] in 1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <bc5a3d4303744676b3b36f4254bb697d>:0 at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\agent_work\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:193 at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0002a] in D:\agent_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:77 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\agent_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:45 at Xamarin.Forms.Platform.iOS.VisualElementRenderer
1[TElement].SetElement (TElement element) [0x000cc] in 1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in <bc5a3d4303744676b3b36f4254bb697d>:0 at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\agent_work\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:193 at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0002a] in D:\agent_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:77 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\agent_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:45 at Xamarin.Forms.Platform.iOS.VisualElementRenderer
1[TElement].SetElement (TElement element) [0x000cc] in
So the issue is inside this:
public override CGSize IntrinsicContentSize => new CGSize(NoIntrinsicMetric,
Math.Max(LowerHandleImageNormal.Size.Height, UpperHandleImageNormal.Size.Height) + SpaceAboveThumbs);
it seems that LowerHandleImageNormal is null, and LowenHandleImageNormal is:
private UIImage LowerHandleImageNormal
{
get
{
if (_lowerHandleImageNormal != null)
return _lowerHandleImageNormal;
if (IS_PRE_IOS7())
{
var image = ImageFromBundle(Enabled ? @"slider-default-handle" : @"slider-default-handle-disabled");
_lowerHandleImageNormal = image.ImageWithAlignmentRectInsets(new UIEdgeInsets(0, 2, 0, 2));
}
else
{
var image = ImageFromBundle(Enabled ? @"slider-default7-handle" : @"slider-default7-handle-disabled");
_lowerHandleImageNormal = image.ImageWithAlignmentRectInsets(new UIEdgeInsets(-1, 8, 1, 8));
}
return _lowerHandleImageNormal;
}
}
and I'm on iOS 11, so that if the "else" branch which cause the null reference exception.
I ran the Samples demo and it works, I took the Sample example and inserted it into my project as first page.. and I got the exception.
Ok.. now I just copied all the slider*.png into my Resorce folder of the iOS project, and now it works.
@halkar , may you fix it? (also the missing nuget dependency from Xamarin.RangeSlider)
Is this fixed yet? Because, Still I'm getting the error.
No, I need time to fix it (and I don't have it). @Magic73 mentioned a workaround which you can use.
PR #138 looks like it would fix this bug, can we merge the change and release a new version @halkar?
@Pezzman unfortunately it doesn't
@Magic73 thank you, your work around worked for me
Did you resolve the issue that was preventing the Xamarin.Forms version from working in iOS? Based on the comments, it does not appear so.
I use it on all of the three Platform.
From following the comments, I am understanding that you were able to implement a workaround successfully, and all 3 platforms work for you, but that workaround did not fix it for everybody. Is that correct?
I can't even reference this properly on iOS my refs have a yellow exclaimation mark and in code R# cannot find the RangeSlider class ... odd.
Resolution
[assembly: Xamarin.Forms.ExportRenderer(typeof(Xamarin.RangeSlider.Forms.RangeSlider), typeof(Xamarin.RangeSlider.Forms.RangeSliderRenderer))]
var t1 = typeof(Xamarin.RangeSlider.RangeSliderControl);
var t2 = typeof(RangeSliderRenderer);
thanks @navkar that worked for us!
Can you create a sample project for the solution and when do you update the repository ?
Thanks
It is working for me also
Thanks It's working for me :)
Please where i can get the Png slider files
slider not visible on iOS and after suggested code is added:
if NETFX_CORE
[assembly: Xamarin.Forms.Platform.WinRT.ExportRenderer(, typeof(Xamarin.RangeSlider.Forms.RangeSliderRenderer))]
else
[assembly: Xamarin.Forms.ExportRenderer(typeof(Xamarin.RangeSlider.Forms.RangeSlider), typeof(Xamarin.RangeSlider.Forms.RangeSliderRenderer))]
endif
NullReferenceException thrown
project: Test.zip