I am trying to create something like this here.
Here is the sample code which I tried:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *simpleTableIdentifier = @"RefundMeCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
UIImageView *rowImageView=(UIImageView*)[cell viewWithTag:1];
UILabel *questionOptionLabel=(UILabel*)[cell viewWithTag:2];
UIImageView *collapseImageView=(UIImageView*)[cell viewWithTag:3];
UIScrollView *scrollView=(UIScrollView*)[cell viewWithTag:4];
UIImageView *sampleImageView=(UIImageView*)[cell viewWithTag:5];
UIButton *sampleButton=(UIButton*)[cell viewWithTag:6];
UILabel *instructionHeaderLabel=(UILabel*)[cell viewWithTag:7];
UILabel *instructionsLabel=(UILabel*)[cell viewWithTag:8];
UIPageControl *pgCntrl=(UIPageControl*)[cell viewWithTag:9];
[rowImageView setImage:[UIImage imageNamed:@"normalcell.png"]];
questionOptionLabel.text = @"";
collapseImageView.image = nil;
scrollView.hidden = YES;
sampleImageView.image = nil;sampleImageView.hidden = YES;
sampleButton.hidden = YES;
instructionHeaderLabel.text = @"";instructionHeaderLabel.hidden = YES;
instructionsLabel.text = @"";instructionsLabel.hidden = YES;
pgCntrl.hidden = YES;
[sampleButton addTarget:self action:@selector(userImageButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
sampleImageView.image = nil;
[collapseImageView setImage:[UIImage imageNamed:@"down.png"]];
questionOptionLabel.text=@"";
instructionHeaderLabel.text=@"Instructions";
if (indexPath.row == 0)
{
instructionHeaderLabel.hidden = NO;
sampleImageView.image = self.barcodeImage;
scrollView.hidden = NO;
scrollView.delegate = self;
pgCntrl.hidden = NO;
sampleImageView.hidden = NO;
sampleButton.hidden = NO;
pgCntrl.numberOfPages = 5;
pgCntrl.currentPage = 0;
for (int i = 0; i<5; i++)
{
[scrollView addSubview:sampleImageView];
[scrollView addSubview:sampleButton];
}
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * 5, scrollView.frame.size.height);
}
else
{
instructionHeaderLabel.hidden = NO;
sampleImageView.image = nil;
scrollView.hidden = NO;
scrollView.delegate = self;
pgCntrl.hidden = NO;
sampleImageView.hidden = NO;
sampleButton.hidden = NO;
pgCntrl.numberOfPages = 3;
pgCntrl.currentPage = 0;
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * 3, scrollView.frame.size.height);
}
return cell;
}
My problem is, how I can add UIImageView
, UILabel
, etc when UIScrollView
is scrolled to second page?
It should look like this
Currently UIImageView
, UILabel
is shown only first time. when I scroll to second page, UIImageView
and UILabel
scroll back and nothing is shown on second page.