Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

scrollViewDidScroll not called

I have a custom tab bar with a horizontal scroll view underneath that. Tab bar contains 5 buttons each of them calls one of five custom keyboards (they are placed on a scroll view). You can switch between these keyboards scrolling the scroll view or pressing the buttons.

Initial question: how do I change the state of the buttons (default/selected) when I switch between keyboards using scroll view?

UPD: I've found out that I need to use scrollViewDidScroll function. By some reason it does not get called. I have an array with all 5 tab bar buttons -
@IBOutlet var tabBarButtons: [UIButton]!

Then I use scrollViewDidScroll: func scrollViewDidScroll(keyboardScrollView: UIScrollView) { if keyboardScrollView.contentOffset == CGPoint(x: 0, y: keyboardScrollView.contentOffset.y) { tabBarButtons[0].isSelected = true } }

Repo: github.com/Rudko/boo

I'm a little confused on how you are presenting the keyboards other then the tab bar. Are you using a PickerView? UIScrollView is for scrolling images that are to big for the screen, not for picking things out of a list.

1 Answer

I have a custom tab bar and ui scroll view (with paging enabled) right under that. I don't use picker view. You can place as many views on a uiscrollview as you want.