Group Group Group Group Group Group Group Group Group

Chapter 8 - When changing color, displaying the current


#1

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.


#2

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


#3

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:


#4

Thank you very much, it works perfectly.