Question

J'ai une sous-classe iPad UIView (nous appellerons LargerUIView) avec laquelle je fais un tas de dessin via drawRect: une fois demandé. Que tout semble fonctionner, et regarde comme je l'aime. Je suis maintenant au point d'essayer d'obtenir le défilement de travail (juste à l'horizontale pour commencer), mais lorsque je tente de faire défiler, ce qui montre ci-dessous est noir (c.-à-semble avoir jamais été dessiné). Cela ne me surprend pas car il a été probablement coupé. Vous cherchez des suggestions. Voici ce que je fais jusqu'à présent:

MyAppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    CGRect scrollRect = CGRectMake(0, 0, 768, 1024);
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:scrollRect];

    LargerUIView *view = (LargerUIView *)[viewController view];
    [scrollView addSubview:view];

    [scrollView setContentSize:CGSizeMake(768, pageHeight)];
    [scrollView setContentMode:UIViewContentModeRedraw];
    [scrollView setClipsToBounds:YES];

    [window addSubview:scrollView];
    [scrollView release];

    // Without this next line, the "frontmost" (ie, most recently added subview)
    // is the target uiview - which is not equipped to handle scrolling/UIEvents
    [window sendSubviewToBack:view];

    // Show it all.
    [window makeKeyAndVisible];

    return YES;
}

Toutes les suggestions? Ont essayé de changer "setClipsToBounds" NO ainsi.

Était-ce utile?

La solution

Soupir. Quel étourdi. Le LargerUIView a été créé pour être plus petite InterfaceBuilder. Vous avez oublié d'ajouter une ligne comme ceci:

[view setBounds:CGRectMake(0, 0, 768, pageHeight)];

Oops.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top