Pregunta

Tengo una subclase UIView iPad (que llamaremos LargerUIView) con la que hago un montón de dibujo a través de drawRect: una vez le preguntó. Que todo parece estar funcionando, y mira como me gusta. Estoy en el punto ahora de tratar de conseguir trabajo de desplazamiento (justo a la horizontal para empezar), pero cuando intento para desplazarse, lo que se muestra a continuación es negro (es decir, parece que nunca se han dibujado). Eso no me sorprende ya que probablemente ha sido recortado. En busca de sugerencias. Esto es lo que estoy haciendo hasta ahora:

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;
}

¿Alguna sugerencia? Han intentado cambiar "setClipsToBounds" a NO también.

¿Fue útil?

Solución

suspiro. Que tonto. El LargerUIView se estableció a ser menor en InterfaceBuilder. Se olvidó de añadir una línea como la siguiente:

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

Vaya.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top