Pergunta

Eu tenho uma subclasse iPad Uiview (vamos ligar para o maior, com o qual faço um monte de desenho via drawrect: uma vez perguntado. Tudo isso parece estar funcionando e parece do jeito que eu gosto. Agora estou no ponto de tentar rolar funcionar (apenas na horizontal para começar), mas quando tento rolar, o que mostra abaixo é preto (ou seja, parece nunca ter sido desenhado). Isso não me surpreende, pois provavelmente foi cortado. Procurando sugestões. Aqui está o que estou fazendo até agora:

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

Alguma sugestão? Tentei alterar os "setClipstobounds" para não.

Foi útil?

Solução

Suspirar. Que bobo. O Laintuiview foi configurado para ser menor no interfaceBuilder. Esqueci de adicionar uma linha como esta:

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

Opa.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top