NSRangeException on setting CurrentPageIndicatorTintColor UIPageControl

I am trying to change the color properties of an object UIPageControlfrom code. However, he is falling. Setting properties from Interface Builder is very simple.

Code:

float x = isLight ? 0.8f : 0.2f;
UIColor markedColor = UIColor.FromRGB (x, x, x);
pageControll.CurrentPageIndicatorTintColor = markedColor;
pageControll.PageIndicatorTintColor = isLight ? UIColor.White : UIColor.Black;

The error I get (in the third line):

Objective-C exception thrown. Name: NSRangeException Reason: *** -[__NSArrayM objectAtIndex:]: index 4294967295 beyond bounds for empty array

Any ideas?

+4
source share
1 answer

Found a problem. This seems to be a bug in the SDK.

Since I have not yet received the data to “populate” the UIPageControl, the property has Pagesbeen set to 0. Changing this to 1 enabled it.

float x = isLight ? 0.8f : 0.2f;
UIColor markedColor = UIColor.FromRGB (x, x, x);
if (pageControll.Pages < 1) {
    pageControll.Pages = 1;
}
pageControll.CurrentPageIndicatorTintColor = markedColor;
pageControll.PageIndicatorTintColor = isLight ? UIColor.White : UIColor.Black;
+10
source

All Articles