2012-11-16 36 views
1

我有一個頁面滾動視圖,它使用圖像來顯示不同的頁面,我期待把按鈕放在不同的頁面上,但我不太確定如何去關於它。滾動視圖中的按鈕與頁面

這裏是我當前的代碼:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    // add the first image (image1) into the last position 
    [self addImageWithName:@"image1.jpg" atPosition:0]; 

    scrollView.contentSize = CGSizeMake(2272, 320); 
    [scrollView scrollRectToVisible:CGRectMake(568,0,0,320) animated:NO]; 

    // add the last image (image4) into the first position 
    [self addImageWithName:@"image4.jpg" atPosition:5]; 

    // add all of the images to the scroll view 
    for (int i = 1; i < 4; i++) { 
     [self addImageWithName:[NSString stringWithFormat:@"image%i.jpg",i] atPosition:i]; 
    } 
} 
-(void)viewDidAppear:(BOOL)animated { 
    [self.navigationController setNavigationBarHidden:NO animated:YES]; 
} 
- (void)addImageWithName:(NSString*)imageString atPosition:(int)position { 
    // add image to scroll view 
    UIImage *image = [UIImage imageNamed:imageString]; 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 
    imageView.frame = CGRectMake(position*568, 0, 568, 320); 
    [scrollView addSubview:imageView]; 
} 

回答