标签: uipageviewcontroller

如何将阴影背景白色更改为其他颜色

我正在尝试UIPageViewController在进行翻转动画时改变阴影颜色.但它总是只显示白色.如何将翻转背景颜色白色的颜色更改为其他颜色(黑色或sephia).iBook也在做同样的事情.

我提到下面的图像有白色bg,颜色我会改变.

截图: 在此输入图像描述

ios uipageviewcontroller

8
推荐指数
2
解决办法
2964
查看次数

在UIPageViewController中释放未使用的页面

我正在为基于图画书的每个基页使用单独的.h,.m.xib文件.每个页面都加载了动画,音乐等,并占用大约4MB的内存.在Instruments中,每个页面加载时,可用内存下降约4MB.翻页时,永远不会释放此内存.它最终会给出内存警告. 似乎保持每个页面在内存中实例化,并且不会卸载它.因此,当页面快速转动时,应用程序崩溃.UIViewControllerUIPageViewControllerUIPageViewController

我希望能够卸载除了UIPageViewController前一页,当前页和下一页所需的3页以外的所有页面.如何卸载不需要的页面,因为它们被实例化了UIPageViewController.

下面是UIPageViewController从中拉出的页面数组.所有页面(Page1,Page2等)基本上只是加载图像文件,提供基本动画和音乐.

    //ARRAY OF PAGES    
pageArray = [[NSArray alloc] initWithObjects:
        (id)[[Page1 alloc] initWithNibName:nil bundle:nil],
            [[Page2 alloc] initWithNibName:nil bundle:nil],    
            [[Page3 alloc] initWithNibName:nil bundle:nil],    
            [[Page4 alloc] initWithNibName:nil bundle:nil],    
            [[Page5 alloc] initWithNibName:nil bundle:nil],    
            [[Page6 alloc] initWithNibName:nil bundle:nil], 
            [[Page7 alloc] initWithNibName:nil bundle:nil],
            [[Page8 alloc] initWithNibName:nil bundle:nil],
             // continues all the way up to page 47
             [[Page47 alloc] initWithNibName:nil bundle:nil],
             nil];
Run Code Online (Sandbox Code Playgroud)

我遗漏了标准的初始化UIPageViewController.它使用" nextPageNumber"从pageArray上面拉出右页以创建新的页面对象. …

xcode memory-management ios automatic-ref-counting uipageviewcontroller

8
推荐指数
1
解决办法
9203
查看次数

将(垂直)UIPageViewController嵌套在另一个(水平)UIPageViewcontroller中

我的问题很严重UIPageViewController.我想使用部分和子部分在我的应用程序中显示内容.所以,我创建了"两个"实例UIPageViewController- 水平(红色)和垂直(蓝色):

方案

之前我说过我已经创建了"两个"实例 - 这不是真的 - 可能有几十个实例,但同时只有两个实例,你知道我的意思.两个控制器都transitionStyle设置为UIPageViewControllerTransitionStyleScroll.

红色UIPageViewController负责部分之间的水平滚动,蓝色负责垂直滚动.

它们在分开时都可以工作,但是当我将垂直放置UIPageViewController在水平方向时,垂直方向会停止工作.

我的代码如下:


横向UIPageViewController创作

self.mainPageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:@{UIPageViewControllerOptionInterPageSpacingKey:[NSNumber numberWithFloat:0]}];
self.mainPageViewController.dataSource = self;
self.mainPageViewController.delegate = self;

self.pdfDocsURLs = @[ @{@"v":[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"1v" ofType:@"pdf"]],
                        @"h":[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"1h" ofType:@"pdf"]]},

                      @{@"v":[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"2v" ofType:@"pdf"]],
                        @"h":[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"2h" ofType:@"pdf"]]},

                      @{@"v":[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"3v" ofType:@"pdf"]],
                        @"h":[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"3h" ofType:@"pdf"]]}];

UIIndexedPageViewController *pvc …
Run Code Online (Sandbox Code Playgroud)

iphone nested objective-c uiviewcontroller uipageviewcontroller

8
推荐指数
1
解决办法
4194
查看次数

UIPageViewController可访问性或画外音

我正在使用UIPageViewController来浏览页面(UIViewController数组).我将页面视图控制器推到顶部导航控制器上.

当我启动应用程序时,我可以翻阅页面视图控制器内的所有VC.但是,页面视图控制器上的"三指滑动"不起作用.它只是没有得到滚动事件.

对这里出了什么问题的任何见解?

accessibility voiceover uipageviewcontroller uiaccessibility

8
推荐指数
1
解决办法
1168
查看次数

无限滚动UIPageViewController

我正在尝试设置一个UIPageViewController可以通过NSUrlConnection数据拉动动态加载页面视图无限滚动.我从3个观点开始:prev,curr,next; 并在到达pageData阵列中的第一个或最后一个视图时加载其他视图.

麻烦的是我在viewControllerBeforeViewController或中加载了其他视图viewControllerAfterViewController.在页面之间进行单次滑动时,似乎可以调用这些方法2-3次.它们也可以在从不完成页面转换的半滑动期间调用.这可能意味着多个预加载开始过早完成.然后不知何故pageViewController忘记了当前的位置.

[self.pageViewController setViewControllers:@[[self.pageData objectAtIndex:gotoIdx]] direction:direction animated:NO completion:nil];
Run Code Online (Sandbox Code Playgroud)

下面使用此行来表示添加数据pageViewController,并转到适当的视图.当我开始使用它时,它不是通过滑动进入上一个/下一个视图,而是开始跳转到看似随机的视图.一旦我开始前进向后滑动......

是否有更合适的地方进行预加载,仅在页面转换完成后调用一次?并且,是否必须调用上面的行,或者是否有更可靠的方法来确保它进入正确的页面?感到很沮丧试图在这里连线.

 // the init line, somewhere early on.  uses Scoll style
 self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationVertical options:nil];

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
    NSUInteger index = [self.pageData indexOfObject:viewController];
    if(index == 1){
        // if loading last one on start, preload one more in advance
        [self loadSecondaryCalData:-1 endView:[[self viewControllerAtIndex:index-1] retain]];  
    } else if ((index == 0) …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uipageviewcontroller

8
推荐指数
1
解决办法
5152
查看次数

iOS:UIPageViewController - 使用按钮跳转到下一页

我在PageViewController中有一系列VC,用户用手指从左到右导航.我需要添加按钮,这些按钮基本上执行与手指滑动相同的操作,通过VC向左或向右移动一个按钮.我怎样才能做到这一点?现在我使用这两种方法动态设置VC作为用户滑动:

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController          viewControllerBeforeViewController:(UIViewController *)viewController;

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController;
Run Code Online (Sandbox Code Playgroud)

如果用户点击按钮,我可以做同样的事吗?

uibutton ios uipageviewcontroller

8
推荐指数
1
解决办法
2万
查看次数

UIPageViewController:子控制器在滚动期间忽略状态栏高度

我遇到了一些问题UIPageViewController.如果我滚动到了新的一页,新的视图控制器是落后的状态栏,而我在滚动.滚动后,视图控制器将自身置于状态栏下方.

我正在使用Storyboard(Universal).UIPageViewController有属性Extend Edges: Under Top Bars.我错过了什么?

在此输入图像描述

  • 设置automaticallyAdjustsScrollViewInsets为false不起作用
  • 使用edgesForExtendedLayout = UIRectEdge.None也没有用
  • 在这里找到一些开放的问题,但没有答案(链接)

UPDATE

跳跃的另一个原因是来自'Constraints'的'边缘'(在这里找到).如果使用约束,请确保取消选中边距(右对话框).您可以稍后在"实用程序"中将其删除(左侧对话框).检查两个连接的视图!

在此输入图像描述

statusbar ios uipageviewcontroller

8
推荐指数
1
解决办法
1656
查看次数

UIPageViewController,预览下一页

我真的需要将一个UIPageViewController应用到我的应用程序中,以便在水平滚动视图中显示n个对象.到现在为止,一切都还可以.

但问题是布局是自定义的,我需要显示一些"下一页"(如下图所示):

在此输入图像描述

我试图设置clipToBoundsfalse PageViewController以及加载的控制器,但它似乎不起作用.

所以我想知道是否有某种方法可以使用它UIPageViewController或者我应该改变方法并使用另一个组件UICollectionView(在这种情况下我不想遵循的方式).

iphone ios uipageviewcontroller swift

8
推荐指数
0
解决办法
964
查看次数

子视图滚动不能正常工作SWIFT

目标:使视图控制器具有多个页面并且可以通过分段控制器进行交换,页面内容可以垂直滚动

细节:

  • 我制作了一个pagviewcontroller并将其作为子视图嵌入到主视图控制器中

    //add pageviewcontroller as subview to viewcontroller
    if let vc = storyboard?.instantiateViewControllerWithIdentifier("ProfileEditController"){
    
        self.addChildViewController(vc)
        self.view.addSubview(vc.view)
    
        EditTabs = vc as! UIPageViewController
        EditTabs.dataSource = self
        EditTabs.delegate = self
    
        //define First page
        EditTabs.setViewControllers([pagesAtIndexPath(0)!], direction:.Forward, animated: true, completion: nil)
        EditTabs.didMoveToParentViewController(self)
    
        //bring segmented view buttons to front of pageViews
        self.view.bringSubviewToFront(self.topTabs)
    }
    
    Run Code Online (Sandbox Code Playgroud)
  • 我调用了pageViewController函数,我通过恢复标识符添加页面

  • 我通过获取pageindex并设置viewcontroller来管理分段视图控制器,如下所示:

    EditTabs.setViewControllers([pagesAtIndexPath(0)!], direction:.Reverse, animated: true, completion: nil)
    
    Run Code Online (Sandbox Code Playgroud)
  • 在故事板中,子页面内部具有滚动视图以保存内容

  • 我测试了子页面滚动视图,通过segue调用它并且工作正常

案件:

  • 一切正常只有子页面的滚动视图根本不起作用

如何解决这个问题?我们非常感谢您的指导方针

谢谢,

addsubview ios uipageviewcontroller swift2

8
推荐指数
1
解决办法
902
查看次数

UIPageViewController的第二页和第三页闪烁为白色

我有一个pageviewcontroller,但当我滑到第二页时,它显示正确的控制器一瞬间,然后屏幕变白,如果我然后再次滑动它将显示应该是.它还有4页而不是我想要的3页.

这是一个演示此问题的视频:https://streamable.com/i1inq

索引如下:

 profileController.index = 0
 discoverController.index = 1
 matchController.index = 2

func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController?
{
    if index == 0
    {
        index = discoverController.index
        return discoverController
    }
    else if index == 1
    {
        index = matchController.index
        return matchController
    }

    return nil
}
Run Code Online (Sandbox Code Playgroud)

编辑:我还应该提到初始控制器是profileController,因此当应用程序运行时索引从0开始.

ios uipageviewcontroller swift

8
推荐指数
1
解决办法
549
查看次数