Tag: uipageviewcontroller

uipageviewcontroller类在设置多个视图控制器时崩溃

我的应用程序不断崩溃,当我在我的应用程序中设置多个视图控制器,如下所示。 [self setViewControllers:_images direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL]; 我的图像是一个视图控制器的数组。 该应用程序崩溃说以下错误。 我不知道从哪里开始。 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'The number of view controllers provided (9) doesn't match the number required (1) for the requested transition

UIPageViewController的进展

我想在页面滚动过程中从uipageviewcontroller收到更新。 我想知道在%的transitionProgress。 (当用户移动手指以获得另一个页面时,该值应该更新)。 我感兴趣的是从一个页面到另一个页面的animation进度,而不是整个页面的进度。 到目前为止我发现的是: 有一个名为UICollectionViewTransitionLayout的类,它具有与我正在查找的属性“transitionProgress”相对应的属性。 可能uipageviewcontroller以某种方式实现这个方法? 我可以在uipagecontroller上调用下面的方法,但是结果只有0! CGFloat percentComplete = [self.pageViewController.transitionCoordinator percentComplete];

在UIPageViewController中调整UIImageView的大小问题

我正在构build一个新的应用程序,并希望在开始时有一个“欢迎演练”,其中有一个包含UIPageViewController中呈现的一系列图像的故事板。 我有它加载图像和所有这一切都很好,但是图像的大小,每当他们超越了“先前”或“下一个”ViewController。 我正在使用Swift进行开发。 这是一个问题的video:http: //youtu.be/dXcjjT-8Bk0 我已经尝试了所有不同的视图模式(方面适合,方面填充,重绘等),他们都performance相同。 我正在使用Auto-Layout + Size Classes,因为我希望简化不同屏幕尺寸的开发。 目前的限制,使UIImage出现在正确的大小是: Align Centre X to Superview Top Space to Top Layout Guide Bottom Space to Bottom Layout Guide + Equals: 50 我目前正在使用Aspect Fit ,它给了我正确的图像(在他们完成了“调整行为”之后)。 任何人都可以进一步指导我如何解决这个问题?

在UIPageViewController中释放未使用的页面

我为基于UIPageViewController的图片书的每个基于UIViewController的页面使用单独的.h , .m和.xib文件。 每个页面加载animation,音乐等,大约需要4MB的内存。 在乐器中,随着每个页面的加载,可用内存下降大约4MB。 这个内存从不被释放,因为页面被转动。 它最终会给出内存警告。 UIPageViewController似乎保持它在内存中实例化的每个页面,并不会卸载它。 所以,当页面变快,应用程序崩溃。 我希望能够卸载除UIPageViewController所需的3个页面之外的所有页面 – 前一页,当前页和下一页。 我怎样才能卸载不受欢迎的页面,因为它们是由UIPageViewController实例化的。 以下是UIPageViewController取出的页面的数组。 所有的页面(Page1,Page2等)基本上只是加载图像文件,提供基本的animation,并有音乐。 //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], […]

如何在使用UIPageViewController时将UIBarButtonItem添加到NavigationBar

请原谅我,已经有很多关于如何将UIBarButtonItem添加到NavigationBar的问题,但我似乎无法得到任何解决scheme在我的情况下工作。 这里是一个简单的testing应用程序,我一直在学习UIPageViewController的布局。 我有页面视图控制器很好地工作与三个独特的viewControllers。 我现在想为每个视图控制器设置唯一的rightBarButtonItems 。 我可以在DetailViewController简单地设置一个通用的barButtonItem 。 UIBarButtonItem *newButton = [[UIBarButtonItem alloc] initWithTitle:@"Whatever" style:UIBarButtonItemStylePlain target:self action:@selector(doSomething)]; self.navigationItem.rightBarButtonItem = newButton; 鉴于我需要在pageViewController中的三个页面的每一个独特的button,我不能在detailViewController设置button。 我已经尝试了三个控制器的viewDidAppear上面的代码,但不会出现button。 我也尝试以相同的方式创buildbutton,然后像这样设置,没有运气。 DetailViewController *vc = [[DetailViewController alloc] init]; vc.navigationItem.rightBarButtonItem = newButton; 我知道我在这里附近,我只是不知道如何指定我需要添加一个button导航栏的NavigationController运行detailViewController我的contentViewControllersembedded英寸任何帮助将是伟大的ESPECIALLY SNIPPETS。 作为一个方面的说明,我已经尝试了一些其他方法已经出现问题。 在viewDidLoad设置button,而不是viewDidAppear 这将无法正常工作,因为每次从一个页面滑动到另一个页面时都不会调用viewDidLoad方法。 viewDidAppear方法是,所以我想在那里设置button。 有可能viewWillAppear每次调用,但我没有检查。 在UIPageViewController委托方法中设置button 这是有问题的,如果用户翻翻页面以快速button将无法更改或无法显示。 解 原来我很接近…而不是在UIPageViewController方法中创buildbutton,我只需要在我的三个视图控制器中的每一个中创build一个navigationItem属性。 当控制器在委托方法中实例化时,我只需将navigationItem属性设置为与detailViewController相同。 在我的viewDidApper方法中,我可以创buildbutton。 然后在viewWillDisappear我设置buttonnil 。 您也可以在DetailViewController viewdidLoad上创buildbutton,并在viewdidLoad的viewDidAppear中更改文本和操作。 这里是一个例子。 在委托方法中 – (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController […]

如果用户移动得太快,UIPageViewController视图会混乱

我有一个UIPageViewController使用整数来告诉它在哪个页面上。 它的工作正常,但如果用户快速滑动几次,以进一步返回页面,整数的变化比视图做得更快,然后整个事情崩溃了(应用程序认为它是在第7页,当它可能是显示第3页)。 我究竟做错了什么? 我应该用不同的方法告诉我自己在哪里? 谢谢。 – (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController { if (pageNumber == 0) { pageNumber++; NSLog(@"%i", pageNumber); Two *two = [[Two alloc] init]; return two; } else if (pageNumber == 1) { pageNumber++; NSLog(@"%i", pageNumber); Three *three = [[Three alloc] init]; return three; } else if (pageNumber >= 2) { return nil; […]

UIPageViewController转换'非平衡调用开始/结束外观转换为'

当我通过UIPageViewController比它的转换animation更快地导航时,我得到了“ Unbalanced calls to begin/end appearance transitions for <MyDataViewController>的Unbalanced calls to begin/end appearance transitions for <MyDataViewController> ”,并且直到我尝试翻页为止, Unbalanced calls to begin/end appearance transitions for <MyDataViewController>中的两个视图之一才显示出来。 任何人有解决这个错误的想法?

无限滚动UIPageViewController

我试图设置一个UIPageViewController ,可以通过NSUrlConnection数据拉dynamicdynamic加载页面浏览无限滚动。 我从3个观点开始:prev,curr,next; 并在pageData数组中的第一个或最后一个视图到达时加载另一个视图。 麻烦的是,我加载了viewControllerBeforeViewController或viewControllerAfterViewController的额外的意见。 看起来,这些方法可以被称为2-3次之间做一个单一的页面之间滑动。 他们也可以在半滑动过程中调用,从不完成页面转换。 这可能意味着多个预加载开始过早完成。 然后以某种方式pageViewController忘记当前的位置。 [self.pageViewController setViewControllers:@[[self.pageData objectAtIndex:gotoIdx]] direction:direction animated:NO completion:nil]; 这行在下面用于表示在pageViewController添加数据,并转到相应的视图。 当我开始使用它时,而不是通过滑动进入prev / next视图,它开始跳转到看似随机的视图。 一旦我开始往前走时向后滑动… 是否有一个更适合的地方做预加载,只在页面转换完成后调用一次? 而且,是否必须调用上面的行,还是有一个更可靠的方法来确保它进入正确的页面? 感到沮丧尝试在这里连线。 // 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){ […]

UIQueuingScrollView didScrollWithAnimation中的断言失败:force:

我有一个UIPageViewController设置分页我的ImageViewController 。 ImageViewController里面包含一个带有UIImageView的UIScrollView 。 没有其他的。 我正在testing在我的数据源为UIPageViewController (即三页)的3“项目”。 这一切工作正常,我可以滚动和缩放,然后页面约30秒,然后突然我得到这个警告… *** Assertion failure in -[_UIQueuingScrollView _didScrollWithAnimation:force:], /SourceCache/UIKit/UIKit-2372/_UIQueuingScrollView.m:778 我不知道在哪里开始debugging,因为它不指向我的任何代码,也没有任何我的代码在堆栈或任何东西。 有人可以给我一个指针,从哪里开始debugging。 编辑 我做了更多的testing。 它似乎发生,如果scrollView正在减速(即轻弹后),然后我试图将PageViewController过渡到另一个ViewController作为scrollview仍在移动。 该应用程序通过转换到下一页崩溃了大约20%的方式。 编辑2 该错误似乎停止_cache_getImp行(不知道如果这是一个大写我小写的L)。 编辑3 这会好起来的 我刚刚下载了Apple的PhotoScroller示例应用程序,看看他们是否以不同的方式解决了问题。 那么,不,他们没有。 示例应用程序崩溃的方式完全一样,我的! 您必须同时缩放和滚动并转换页面,以使其更容易崩溃,但也会发生在自己身上,这可能需要更长的时间才能发生。

如何用UIScrollView实现UIPageViewController?

我从苹果网站上拿了Photo Scroller的例子,并试图通过复制代码来实现我自己的Album。 现在, UIScrollView不可见。 我如何让它出现? 我唯一的代码更改是在创buildUIPageViewController 。 在我的情况下,这是一个UIViewController打开它,而不是AppDelegate 。 @implementation BasePhotoViewController – (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nil bundle:nibBundleOrNil]; if (self) { // kick things off by making the first page PhotoViewController *pageZero = [PhotoViewController photoViewControllerForPageIndex:0]; if (pageZero != nil) { // assign the first page to the pageViewController (our rootViewController) //UIPageViewController […]