如何在Objective-c中的页面视图控件中设置页码

时间:2016-01-19 05:10:54

标签: ios uipageviewcontroller

如何使用Objective-c中的导航项为每个页面在页面视图控件的顶部设置页码?

self.navigationItem.title=[NSMutableString stringWithFormat:@"(%lu to %lu)",(unsigned long)_dataArray.count,(unsigned long)_indexpath.row+1];

2 个答案:

答案 0 :(得分:0)

试试这个:

SELECT Id, Qty, COUNT(Id) 
FROM table
GROUP BY Id
HAVING ( COUNT(Id) > 1 );

答案 1 :(得分:0)

试试这个对我有用。

  - (UIViewController *)pageViewController:(UIPageViewController 


  *)pageViewController viewControllerBeforeViewController:(UIViewController


 *)viewController

  {
  NSUInteger index = ((PageViewController*) viewController).pageIndex;

  indexpaths=index;

  self.navigationItem.title=[NSMutableString stringWithFormat:

  @"(%lu to %lu)",(unsigned long)_dataArray.count,

  (unsignedlong)indexpaths+1];

  if ((index == 0) || (index == NSNotFound)) {

    return nil;

  }
  index--;
   return [self viewControllerAtIndex:index];
  }

 - (UIViewController *)pageViewController:(UIPageViewController 

*)pageViewController viewControllerAfterViewController:(UIViewController 

*)viewController

 {

   NSUInteger index = ((PageViewController*) viewController).pageIndex;

   indexpaths=index;

  self.navigationItem.title=[NSMutableString stringWithFormat:@"(%lu to 

   %lu)",(unsigned long)_dataArray.count,(unsigned long)indexpaths+1];


   if (index == NSNotFound) 
     {

     return nil;

   }

   //self.navigationItem.title=[NSMutableString stringWithFormat:@"(%lu

  to %lu)",(unsigned long)_dataArray.count,(unsigned long)indexpaths+1];

  if (index == [self.dataArray count])
   {

    return nil;

  }

 index++;

  return [self viewControllerAtIndex:index];

 }