私はUIScrollView内にいくつかの画像を表示する必要があるiPhoneアプリケーションを作成しています。前の画像。また、下部にはボタンが1つあります。ユーザーがそのボタンをクリックすると、スクロールビューで選択した画像が表示されます。私はスクロールビュー内に複数の画像を表示する方法を知りたいのですが、どの画像がスクロールビュー内にあるかを確認します。iOSのUIScrollView内に複数の画像を表示するには
答えて
例を理解してほしい - nbetweenは、あなたがイメージあなただけのシンプルなindexstart ++またはを見せる左右ボタン.COMあなたのイメージ名の場合
は数字だけではありません。
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[scrollView setPagingEnabled:YES];
[scrollView setAlwaysBounceVertical:NO];
NSArray *imagesArray = [NSArray arrayWithObjects:@"img1.png", @"img2.png", @"img3.png", nil];
for (int i = 0; i < [imagesArray count]; i++)
{
CGFloat xOrigin = i * scrollView.frame.size.width;
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(xOrigin, 0, scrollView.frame.size.width, scrollView.frame.size.height)];
[imageView setImage:[UIImage imageNamed:[imagesArray objectAtIndex:i]]];
[imageView setContentMode:UIViewContentModeScaleAspectFit];
[scrollView addSubview:imageView];
}
[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width * [imagesArray count], scrollView.frame.size.height)];
Apple.developerPhotoScrollerは個別にパンとズームすることができます写真を表示し、ページ付けのためのリッチなユーザー体験を作成するための組み込みUIScrollViewsとCATiledLayerの使用方法を示します。
CATiledLayerは、高解像度画像や大きな写真セットでページング、パン、ズームのパフォーマンスを向上させるために使用されます。
ああ...これは完全に問題を解決し+1しました! –
あなた単に最初 ランタイムと画像上に新しいビューを作成し、タグ値でタグ1000または100およびインクリメントなどのすべてのビューを割り当て、その後に、このビューを追加scrollview左右移動用の2つのボタンとその出口アクションを作り、あなたは、あなたがこれを使用し、左右ボタンでこれを行うためにループを使用して、この
indexStart=100;
UIView *AddView=[[UIView alloc]initWithFrame:CGRectMake(55, 0, 100, 100)];
AddView.tag=indexStart;
btnTap.tag=indexStart;
UIImageView *imgview=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
[AddView addSubview:imgview];
imgview.image=image;
imgview.tag=1000;
[ScrollView addSubview:AddView];
[imgArray addObject:AddView];
のように可変配列にして、すべてのscrollviewサブビューを追加このコードではeditImgeViewは画像ビューiですユーザーは右または左のボタンを選択した場合
for (int index = 0; index < [imgAddArrayAfter count]; index ++) {
NSLog(@"index %d",index);
UIView *vc=[imgArray objectAtIndex:index];
NSLog(@"view tag %d",vc.tag);
if(vc.tag == indexStart)
{
UIImageView *modalView=(UIImageView *) [vc viewWithTag:1000];
editImgeView.image=modalView.image;
}
}
私はあなたがdanielbeard.wordpressから;-)
- (void)viewDidLoad
{
[super viewDidLoad];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
scrollView.contentSize = CGSizeMake(320, 465);
[scrollView setScrollEnabled:YES];
[scrollView setPagingEnabled:YES];
[scrollView setAlwaysBounceVertical:NO];
[self.view addSubview:scrollView];
NSMutableArray *arrImage = [NSMutableArray arrayWithObjects:@"food1.jpeg", @"food2.jpeg", @"food3.jpeg",@"food4.jpeg", @"food5.jpeg", @"food6.jpeg",@"food7.jpeg", @"food8.jpeg", @"foo9.jpeg",@"food10.jpeg", @"food11.jpeg", @"food12.jpeg",@"food13.jpeg", @"food14.jpeg", @"food15.jpeg", @"food16.jpeg", nil];
for (int i = 0; i < [arrImage count]; i++)
{
CGFloat xOrigin = i * scrollView.frame.size.width;
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(xOrigin, 0, scrollView.frame.size.width, scrollView.frame.size.height)];
[imageView setImage:[UIImage imageNamed:[arrImage objectAtIndex:i]]];
[imageView setContentMode:UIViewContentModeScaleAspectFit];
[scrollView addSubview:imageView];
}
[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width * [arrImage count], scrollView.frame.size.height)];
}
- 1. JSON画像をUIScrollViewに表示
- 2. ActiveAdminで複数の画像を表示するには
- 3. UIScrollviewに複数の画像があり、ピンチしてズームする
- 4. iOSでの画像表示
- 5. Jqueryスクリプトのロードブロッキング:複数のdivに複数の画像を表示/非表示する方法は?
- 6. iOSでHTTPリクエストで複数の画像をアップロードするには?
- 7. iosの画像表示にピンを表示
- 8. watchOSの複雑さに画像を表示するには
- 9. 複数の画像を表形式で表示する - ブラックベリー
- 10. flipview winrtで複数の画像を表示する方法は?
- 11. jQueryの非表示画像は、内容を変更するには、show画像
- 12. iOSは画像の上に画像を上にスライドさせ、下の画像を表示します。 (ラjQuery.slide())
- 13. LeavesViewControllerの1ページに複数の画像を表示する方法は?
- 14. drupalで商品の複数の画像を表示するには
- 15. スクロールバーでTkinterに複数の画像を表示
- 16. Javaスイング - JPanelで複数の画像を動的に表示
- 17. 画像プロットに複数の軸を表示
- 18. グリッドビューで複数の列に画像を表示する方法は?
- 19. Androidでgridview内にランダムな画像を表示するには
- 20. ファイルから複数の画像を表示する
- 21. 複数の画像をロード、表示、変換する
- 22. 複数の画面にアプリケーションを表示
- 23. iPhoneに複数の画像サムネイルを表示するときのUIの歪み
- 24. 複数の画面上の同じ場所に画像を表示| Android
- 25. iOS:複数の起動画像
- 26. OnMouseOverはp:dataTableの各行内に画像を表示します
- 27. ios dropbox、画像のサムネイルを表形式で表示する
- 28. iOSのFacebook投稿用に高品質の画像を表示
- 29. iOS UIScrollView内のUIWebView
- 30. キャンバス内に複数の画像がある場合は
あなたがこれまで何をしています –
ダイレクトコードを手に入れたようですか?それをやったことがありますか? –