Putting ScrollView Inside TabView


I’m a high school student, new to iPhone and Obj-C, and I’m having a bit of trouble putting ScrollView (or, specifically, the version of You Are Getting Sleepy that scrolls and zooms) on a tab in TabView. (I’m playing with a somewhat extended version of the HypnoTime application introduced in Chapter 7.) I have all the code that goes in the app delegate, in the original (separate) version of You Are Getting Sleepy (from Chapter 6), which works fine on its own, but my understanding is that the code needed to implement TabView wouldn’t work with it in the delegate–and, besides, the CGRect couldn’t have its bounds defined as the whole window, anyways (I don’t think).

Has anyone else tried to do this? Does anyone know what I need in terms of views, controllers, etc? Any help, hints, etc would be greatly appreciated. Thanks!


In the book, the HypnosisViewController’s view is an instance of HypnosisView. You have to shim a UIScrollView into that relationship, therefore, the HypnosisViewController’s view needs to be a UIScrollView and the UIScrollView’s subview needs to be the HypnosisView.

The delegate for the scroll view will be the HypnosisViewController. You are essentially moving the code from application:didFinishLaunchingWithOptions: in the earlier exercise to HypnosisViewController’s loadView method. The difference will be that instead of adding the scroll view to the window as you did in chapter 6, you will be invoking setView: with the scroll view as the argument.