2011-12-26 2 views

답변

1

사용하십시오있는 ScrollView는 동안 그 작업을 수행 :

UIScrollView * scroller = [[[UIScrollView alloc] initWithFrame:CGTectMake(0, 0, 320, 480)] autorelease]; 
scroller.pagingEnabled = YES; 
[self.view addSubview:scroller]; 

int x = 0; 

for (int i = 0; i < [yourArray count]; i++){ 

    UIImageView * myImageview = [[[UIImageView alloc] initWithFrame:CGRectMake(x, 0, 320, 480)] autorelease]; 
    [myImageview setImage:[yourArray objectAtIndex:i]]; 
    [scroller addSubview:myView]; 

    x += myView.frame.size.width; 

} 

[scroller setContentSize:CGSizeMake(x, 480)]; 
1

이 코드는 큰 나를 위해 작동 :

self.view.backgroundColor = [UIColor redColor]; 
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
scroll.pagingEnabled = YES; 
NSInteger numberOfViews = 3; 
for (int i = 0; i < numberOfViews; i++) { 
    CGFloat yOrigin = i * self.view.frame.size.width; 
    UIView *awesomeView = [[UIView alloc] initWithFrame:CGRectMake(yOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
    awesomeView.backgroundColor = [UIColor colorWithRed:0.5/i green:0.5 blue:0.5 alpha:1]; 
    [scroll addSubview:awesomeView]; 
    [awesomeView release]; 
    } 
    scroll.contentSize = CGSizeMake(self.view.frame.size.width * numberOfViews, self.view.frame.size.height); 
    [self.view addSubview:scroll]; 
    [scroll release];