0

メイン画面に10個のボタン(画像ボタン)があり、各ボタンがテーブルビューアイテムを含むSQLデータベースにリンクされているソースコードがあります。XIBでは、各ボタンのタグを1、2、3、4で選択します。

これらのボタンをスクロールさせたいのですが、どうすればよいですか?

ビューをスクロールビューに変換しようとしましたが、画像を削除し、スクロールビューにボタンを作成しましたが、各ボタンをテーブルビューのタグにリンクする方法がわかりませんか?

以下は私が使用したものです:

@implementation mainViewController;

@synthesizeマスター; @synthesizeモデル;

  • (void)viewWillAppear:(BOOL)animated {

    UIScrollView * scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,320,480)]; scrollview.showsVerticalScrollIndicator = YES; scrollview.scrollEnabled = YES; scrollview.userInteractionEnabled = YES; [self.view addSubview:scrollview]; scrollview.contentSize = CGSizeMake(320,960);//必要なscrollview.pagingEnabled=YESでこれを編集できます。

    UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(aMethod :) forControlEvents:UIControlEventTouchDown]; [button setTitle:@ "Show View" forState:UIControlStateNormal]; button.frame = CGRectMake(80.0、210.0、160.0、40.0);

    UIImageView * imageview1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@ "c1@2x.png"]]; imageview1.frame = CGRectMake(18.0、18、285,50); [scrollview addSubview:imageview1];

    UIImageView * imageview2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@ "c2@2x.png"]]; imageview2.frame = CGRectMake(18.0、78、285,50); [scrollview addSubview:imageview2];

    UIImageView * imageview3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@ "c3@2x.png"]]; imageview3.frame = CGRectMake(18.0、138、285,50); [scrollview addSubview:imageview3];

    UIImageView * imageview4 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@ "c4@2x.png"]]; imageview4.frame = CGRectMake(18.0、198、285,50); [scrollview addSubview:imageview4];

4

1 に答える 1