我想創建類似於這樣的東西here。UIScrollView與UITableViewCell中的UIPageControl
這裏是我試圖示例代碼:
- (的UITableViewCell *)的tableView:(UITableView的*)的tableView的cellForRowAtIndexPath:(NSIndexPath *)indexPath { 靜態的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"]];
[email protected]"";
[email protected]"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;
}
我的問題是,如何添加UIImageView
,UILabel
,當UIScrollView
被滾動到第二頁等?
它應該是這樣的
http://oi60.tinypic.com/97snib.jpg
目前UIImageView
,UILabel
只顯示第一次。當我滾動到第二頁時,UIImageView
和UILabel
向後滾動,第二頁上不顯示任何內容。
爲什麼你需要添加圖片滾動時?你可以馬上添加它,滾動只會顯示它們嗎? –
@圖片,您可以上傳圖像到網站,如tinypic,並分享鏈接。 @第二頁,你想延遲加載數據?如果這是你想要的,你可能會找到一些開源庫。 :) – Sufian
@OlegFedorov我需要從不同的維度(頂部,底部等)產品圖像和標籤提供說明。 – Maverick