2012-04-16 30 views
0

誰かがScrolling Projectを変更する方法を教えて、他の画像と部分的に左右に表示されるように画像を表示できますか?ページマネージャーに行くときにモバイルサファリと同じように...これは、ユーザーが右にスクロールするともっと多くの画像があることを知るために重要です。 両方の方法はスクローリングプロジェクトから取得しました。 SCROLLVIEWを設定するにはスクロール - 画像からサムネイルを作成

METHOD:レイアウトを設定するために

ViewDidLoad { 

self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor]; 

// 1. setup the scrollview for multiple images and add it to the view controller 
// 
// note: the following can be done in Interface Builder, but we show this in code for clarity 
[scrollView1 setBackgroundColor:[UIColor blackColor]]; 
[scrollView1 setCanCancelContentTouches:NO]; 
scrollView1.indicatorStyle = UIScrollViewIndicatorStyleWhite; 
scrollView1.clipsToBounds = YES;  // default is NO, we want to restrict drawing within our scrollview 
scrollView1.scrollEnabled = YES; 

// pagingEnabled property default is NO, if set the scroller will stop or snap at each photo 
// if you want free-flowing scroll, don't set this property. 
scrollView1.pagingEnabled = YES; 

// load all the images from our bundle and add them to the scroll view 
NSUInteger i; 
for (i = 1; i <= kNumImages; i++) 
{ 
    NSString *imageName = [NSString stringWithFormat:@"image%d.jpg", i]; 
    UIImage *image = [UIImage imageNamed:imageName]; 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 

    // setup each frame to a default height and width, it will be properly placed when we call "updateScrollList" 
    CGRect rect = imageView.frame; 
    rect.size.height = kScrollObjHeight; 
    rect.size.width = kScrollObjWidth; 
    imageView.frame = rect; 
    imageView.tag = i; // tag our images for later use when we place them in serial fashion 
    [scrollView1 addSubview:imageView]; 
    [imageView release]; 
} 

[self layoutScrollImages]; // now place the photos in serial layout within the scrollview 
} 

がMETHOD:私の以前のアプリで

- (void)layoutScrollImages 
{ 
UIImageView *view = nil; 
NSArray *subviews = [scrollView1 subviews]; 

// reposition all image subviews in a horizontal serial fashion 
CGFloat curXLoc = 0; 
for (view in subviews) 
{ 
    if ([view isKindOfClass:[UIImageView class]] && view.tag > 0) 
    { 
     CGRect frame = view.frame; 
     frame.origin = CGPointMake(curXLoc, 0); 
     view.frame = frame; 

     curXLoc += (kScrollObjWidth); 
    } 
} 

// set the content size so it can be scrollable 
[scrollView1 setContentSize:CGSizeMake((kNumImages * kScrollObjWidth), [scrollView1 bounds].size.height)]; 
} 

答えて

1

私はそう、私はスクロールビューの上にいくつかのカスタムボタンを配置画像ゲラビューを作成しますユーザーはそのボタンをクリックするとフル画像を見ることができます。ここ

はコードです、それはあなたが、これが作り出すもののスクリーンショットを投稿することが可能である

 UIScrollView *Sview = [[UIScrollView alloc] 
         initWithFrame:[[UIScreen mainScreen] bounds]]; 

int row = 0; 
int column = 0; 
for(int i = 0; i < self.data.getCustomers.count; ++i) { 

    customerToEdit = [self.data.getCustomers objectAtIndex:i]; 


    NSURL* imgUrl = [NSURL URLWithString:@"your image url array objects"]; 

    UIImage* thumb = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]]; 

    //UIImage *thumb = [_thumbs objectAtIndex:i]; 

    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom]; 

    button.frame = CGRectMake(column*100+24, row*80+10, 64, 64); 

    [button setImage:thumb forState:UIControlStateNormal]; 

    [button addTarget:self 
       action:@selector(buttonClicked:) 
    forControlEvents:UIControlEventTouchUpInside]; 

    button.tag = i; 

    [Sview addSubview:button]; 

    if (column == 2) { 
     column = 0; 
     row++; 
    } else { 
     column++; 
    } 

} 

[view setContentSize:CGSizeMake(320, (row+1) * 80 + 10)]; 
self.view = view; // or u can [self.view addsubview:Sview]; 
+0

あなたを助けることを願っていますか?ありがとう! – Apollo

+0

明日は私のオフィスが近づくので、グリッドビューで画像を表示するので、私は明日お待ちしています。 – freelancer

+0

大変ありがとうございます – Apollo

関連する問題