我已經實現了我的代碼複製類似的android控制完全一樣的...
請參閱我的一些代碼的一部分,你會通過添加視圖來UIScrollView中得到一些想法
我都做到了。 二手2個scrollviews一個用於標題和一個用於表
1.添加表視圖來滾動型爲表
您做生意= 1;
for (Page *page in pageArray)
{
UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
PageContentViewController *contentViewController = [mystoryboard instantiateViewControllerWithIdentifier:@"pageContentViewController"];
contentViewController.detailsDictionary = page.deviceDetailDictionary; //assigning dictionary will use as table data source
/* Content page's x position calculation */
// Formula: xPos = scrollViewWidth * (pageNo -1)
// Where,
// pageNo starts with 1
int xPos = self.detailScrollView.frame.size.width * (pageNo -1);
contentViewController.view.frame = CGRectMake(xPos, 0, self.detailScrollView.frame.size.width, contentViewController.view.frame.size.height);
pageNo ++;
[self addChildViewController:contentViewController];
[self.detailScrollView addSubview:contentViewController.view];
[contentViewController didMoveToParentViewController:self];
}
2.添加UILabels到titleScrollView
只要檢查這個公式來標題的UILabel視圖添加到頂部滾動視圖
// Formula: xPos = 75 + 10 * pageNo + (pageNo -1) * 150;
// Where,
// pageNo starts with 1
// 75 = Left margin of first title
// 10 = Space between two labels
// 150 = Width of label
滾動型的3.使用委託方法(其中你添加了表格)來處理滑動
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
{
CGFloat pageWidth = self.detailScrollView.frame.size.width;
//1. Calculate page no. if 50 percent or more area of any page visible make it as current page
int pageNo = floor((self.detailScrollView.contentOffset.x - pageWidth/2)/pageWidth) + 2;
//2. Make only current page (calculated in 1.) visible by scrolling to that page in detailScrollView
//Formula : xPos = pageWidth * (pageNo -1)
CGRect frame = CGRectMake(pageWidth * (pageNo -1), 0, pageWidth, 50);
[self.detailScrollView scrollRectToVisible:frame animated:YES];//OR set content offset
//3. Make title visible of current page by scrolling to that title in titleScrollView
//Formula : xPos = (pageWidth/2) * (pageNo -1)
CGRect titleFrame = CGRectMake(160 * (pageNo -1), 0, pageWidth, 10);
[self.titleScrollView scrollRectToVisible:titleFrame animated:YES];//OR set content offset
//Fade effect for non current titles
//Set all page title alpha to low value
for (UILabel *title in pageTitleArray)
{
[title setAlpha:0.5];
}
//set current page alpha to 1
UILabel *title = [pageTitleArray objectAtIndex:pageNo -1];
[title setAlpha:1];
}
守則3照顧移動到下一個/上一個頁面上刷卡動畫
希望這將是很好的出發點,你的...
定義「最佳」? – nhgrif
對此方案使用UIPageControl。 –
[UITableview with UIPageControl?]可能的重複?(http://stackoverflow.com/questions/13312119/uitableview-with-uipagecontrol) – calimarkus