Ubah ukuran UIScrollView dengan setcontentsize

Saya mencoba mengubah ukuran UIScrollView di dalam UICOllectionViewCell tetapi tidak mengubah ukurannya.

-(int)resizeScrollView:(int)height{

    NSLog(@"Before Scroll height %f",self.scrollView.frame.size.height);
    float currentHeight=self.scrollView.frame.size.height+height+200;
    NSLog(@"height %f",currentHeight);
    CGSize size=CGSizeMake(self.scrollView.frame.size.width ,
                           currentHeight + 10 );
    [self.scrollView setContentSize:size];    
    self.scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    NSLog(@"After Scroll height %f",self.scrollView.frame.size.height);

    return currentHeight;
}

person user1688346    schedule 22.04.2013    source sumber


Jawaban (1)


Menyetel contentSize menyesuaikan jumlah ruang logis yang digulirkan oleh tampilan gulir. Anda perlu menyetel frame atau bounds untuk menyesuaikan ukuran tampilan gulir di tampilan induknya.

CGRect scrollFrame = self.scrollView.frame;
scrollFrame.size.height += height + 210;
self.scrollView.frame = scrollFrame;
person Seamus Campbell    schedule 22.04.2013
comment
apa konteks yang Anda panggil -resizeScrollView? - person Seamus Campbell; 23.04.2013
comment
ya itu mengubah ukuran tampilan gulir. saya akhirnya membuat ulang bingkai dan menambahkannya ke tampilan gulir. - person user1688346; 23.04.2013