Domanda

ho fatto un UIViewController, che genera programatically un UIScrollView. Va tutto bene, ma quando ho ruotare il dispositivo, l'UIScollView dovrebbe ridimensionare in modo che prende tutta la larghezza del mio punto di vista.

C'è un modo per farlo senza ricostruire l'UIScrollView completo?

Thx un sacco! Sebastian

Questo è chiamato nel mio 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];
}

Poi ho cercato di ridimensionare myScroller con questo, quando ho usato SETFRAME, ho detto myScroller non sarebbe rispondere ad essa ...:

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

E chiamato il metodo didAnimateFirstHalf ... perché io non sto shure dove altro chiamarlo.

Thx un sacco di nuovo !!

È stato utile?

Soluzione

[ScrollView SETFRAME: CGRectMake (x, y, larghezza, altezza)];     // Forse avete bisogno di fare lo stesso per il contenuto del ScrollView per adattarlo il layout

dovrebbe farlo. Puoi avvolgere che in un blocco UIAnimation se ha bisogno di essere una transizione.

Altri suggerimenti

Prova questo:

    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)];
    }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top