Pregunta

I hizo una UIViewController, que genera programáticamente un UIScrollView. todo está bien, pero cuando gira el dispositivo, el UIScollView debe cambiar el tamaño de lo que tarda el ancho completo de mi vista.

¿Hay una manera de hacerlo sin la reconstrucción de la UIScrollView completa?

Thx mucho! Sebastián

Esto se llama en mi viewDidLoad:

    -(void)buildmyScroller {
    myScroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 800, 768, 100)];


    //...adding some subviews to myScroller


    thumbScroller.contentSize = CGSizeMake(3000, 100);
    [[self view] addSubview:myScroller];
}

A continuación, traté de cambiar el tamaño de myScroller con esto, cuando solía setFrame, dije myScroller ¿no responden a ella ...:

-(void)changemyScroller {
        UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;
    if (interfaceOrientation == UIInterfaceOrientationPortrait) {
        [thumbScroller setFrame:CGRectMake(0, 805, 768, 150)];
    }
    else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
        thumbScroller.frame = CGRectMake(0, 805, 768, 150);
    }
    else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
        thumbScroller.frame = CGRectMake(0, 549, 1024, 150);
    }
    else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight){
        thumbScroller.frame = CGRectMake(0, 549, 1024, 150);
    }
}

Y llamó el método de didAnimateFirstHalf ... porque no voy a Shure otro lugar para llamarlo.

Thx mucho otra vez !!

¿Fue útil?

Solución

[ScrollView setFrame: CGRectmake (x, y, anchura, altura)];     // Tal vez lo que necesita hacer lo mismo con el contenido de la ScrollView para que se ajuste a su diseño

debería hacerlo. Que se puede envolver en un bloque de UIAnimation si tiene por qué ser una transición.

Otros consejos

Prueba esto:

    if(self.rowNumber == 0){
    /******************* Scroller Setup *****************/
    // how many pages
    int pageCount = 5;
    //set up the scrollView
    UIScrollView *scroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 768, 960)];
    // support for Landscape Orienation
    if(UIInterfaceOrientationLandscapeLeft){
        [scroller  setFrame:CGRectMake(0,0,1024, 704)];
    }
    if(UIInterfaceOrientationLandscapeRight){
        [scroller  setFrame:CGRectMake(0,0,1024, 704)];
    }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top