images を含む水平スクロール テーブルビューを作成しています。スワイプ機能がうまく機能しており、画像を次のように追加できscrollView
ますcellForRowAtIndexPath
。
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, tv.frame.size.width, 78)];
[scrollView setContentSize:CGSizeMake(700, 78)];
UIImage *footImage = [UIImage imageNamed:@"Foot.png"];
UIImageView *footImageView = [[UIImageView alloc] initWithImage:footImage];
footImageView.frame = CGRectMake(0, 0, 80, 78);
footImageView.userInteractionEnabled = YES;
[scrollView addSubview: footImageView];
UIImage *handImage = [UIImage imageNamed:@"Hand.png"];
UIImageView *handImageView = [[UIImageView alloc] initWithImage:handImage];
handImageView.frame = CGRectMake(90, 0, 80, 78);
handImageView.userInteractionEnabled = YES;
[scrollView addSubview: handImageView];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(highlightImage)];
[scrollView addGestureRecognizer:tapGesture];
NSLog(@"tapGesture added to scrollView");
[[cell contentView] addSubview:scrollView];
pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 50, tv.frame.size.width, 50)];
[pageControl setNumberOfPages:4];
[[cell contentView] addSubview:pageControl];
私tapGesture
はセレクターに登録しており、hightlightImage
このメソッドを正しく呼び出していることをログに記録しています。
- (void) highlightImage
{
NSLog(@"tapping tapping");
}
私が本当に取り組んでいるのは、タップするとこれらの画像を強調表示/選択し、もう一度タップするとそれらを強調表示/選択解除する機能です。次のページに移動する別のボタンを画面に表示します (ここでは関係ありません)。
ここで正しい道を進んでいますか?明らかに、私はNSArray
ofUIImages
を入力し、scrollView
そのように入力しますが、今のところそれをスパイクするだけです. 誰かが私に指示や、各ボタンを個別に選択可能/選択解除可能にする方法の例を教えてくれたら、それは素晴らしいことです:)