Chapter 8 - When changing color, displaying the current

Hello,

This is just a question that does not seems to be addressed in the book, and I wonder if it is even possible. When you tap the “Change Color” button we present a series of paged controllers.

It always displays the first one. What if I want to choose another controller to be displayed first, let’s say, the one of the currently selected color?

I’ve looked for it for quite a while and it does not seems to be even possible (of course, I could rearrange the colors to display the current first, but that’s not the purpose of my question.)

Thanks in advance if someone knows some kind of hack to to that nicely.

@ehabamer Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hello @letatas,
I checked online what you are trying to do.
check becomeCurrentPage(). Adding those lines in "ColorController.awake(withContext:) right after update(color:) will do what you need :]

if ColorManager.defaultManager.selectedColor == color {
    becomeCurrentPage()
}

It is good highlight and it should be mentioned in the book. Thanks for pointing it out. :+1:

Thank you very much, it works perfectly.

This topic was automatically closed after 166 days. New replies are no longer allowed.