如何在UIPageViewController底部添加一个按钮

时间:2016-07-02 16:21:48

标签: ios objective-c button toolbar uipageviewcontroller

我想在我的UIPageViewController中添加一个按钮,就像iOS Weather app的右下角一样。 我想知道什么是最正确和干净的方式。 我应该以某种方式访问​​PageControl并使用我想要添加的按钮添加子视图,还是应该隐藏页面控件并在视图底部添加工具栏? 任何简单的片段都是最受欢迎的。 谢谢!

1 个答案:

答案 0 :(得分:0)

  1. 在viewDidLoad中,将按钮添加到UIPageViewController的视图中。
  2. 在viewDidAppear中,将按钮置于前面
  3. ```

    - (void)viewDidLoad {
      [super viewDidLoad];
    
      // Add the button
      [self.view addSubview:button];
    }
    
    - (void)viewDidAppear:(BOOL)animated {
      [super viewDidAppear:animated];
    
      // Bring it to front so it appears in front of the UIPageControl
      [self.view bringSubviewToFront:button];
    }
    

    ```