Silver Challenge: Where is the textfield/Segmented Control?


#1

Hi all,

I finally have the pinch-to-zoom working but my textfield and my segmented control is missing now. They are implemented in BNRHypnosisViewController.m as done in the book. This is my code in BNRAppDelegate.m. I didn’t change any other code.


#import "BNRAppDelegate.h"
#import "BNRHypnosisViewController.h"
#import "BNRReminderViewController.h"
#import "BNRQuizViewController.h"
#import "BNRHypnosisView.h"

@interface BNRAppDelegate() <UIScrollViewDelegate>

@property (strong, nonatomic) BNRHypnosisView *hView;

@end


@implementation BNRAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    
    CGRect initRect = self.window.bounds;
    CGRect bigRect = initRect;
    
    UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame];
    
    [self.window addSubview:scrollView];
    
    self.hView = [[BNRHypnosisView alloc]initWithFrame:bigRect];
    
    [scrollView addSubview:self.hView];
    
    scrollView.contentSize = bigRect.size;
    scrollView.pagingEnabled = NO;
    scrollView.minimumZoomScale = 0.5;
    scrollView.maximumZoomScale = 3.0;
    scrollView.delegate = self;
    
    BNRHypnosisViewController *hvc = [[BNRHypnosisViewController alloc]init];
    hvc.view = scrollView;
    
    NSBundle *appBundle = [NSBundle mainBundle];
    BNRReminderViewController *rvc = [[BNRReminderViewController alloc]init];
    BNRQuizViewController *qvc = [[BNRQuizViewController alloc]init];
    
    UITabBarController *tabBarController = [[UITabBarController alloc]init];
    tabBarController.viewControllers =@[hvc, rvc, qvc];
    self.window.rootViewController = tabBarController;

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;

}

-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.hView;
}