我正在尝试为UIPageViewController禁用平移手势识别器.
在iOS 5上,我可以遍历它们并禁用它们.
for (UIGestureRecognizer* recognizer in self.pageViewController.gestureRecognizers) {
if ([recognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
recognizer.enabled = NO;
}
}
Run Code Online (Sandbox Code Playgroud)
在iOS 6上使用UIPageViewControllerTransitionStyleScroll,页面视图控制器没有返回手势识别器.
这可归结为:
当UIPageViewController的过渡样式设置为滚动时,self.pageViewController.gestureRecognizers = 0,因此我无法访问手势识别器.
有什么方法可以解决这个问题吗?因为卷曲过渡工作正常,我不认为我做错了什么.
我有一个UIPageViewController
设置寻呼我的ImageViewController
.
该ImageViewController
包含UIScrollView
有一个UIImageView
内部.没有其他的.
我正在测试我的数据源中的3个"项目" UIPageViewController
(即三页).
这一切都很好,我可以滚动和缩放,然后页面约30秒,然后我突然得到这个警告......
*** Assertion failure in -[_UIQueuingScrollView _didScrollWithAnimation:force:], /SourceCache/UIKit/UIKit-2372/_UIQueuingScrollView.m:778
Run Code Online (Sandbox Code Playgroud)
我不知道从哪里开始调试它,因为它没有指向我的任何代码,并且堆栈中没有任何代码或任何东西.
有人可以给我一个指针,指出从哪里开始调试这个.
编辑
我做了一些测试.如果scrollView正在减速(即在轻弹之后)似乎会发生,然后我尝试将PageViewController转换到另一个ViewController,因为scrollview仍在移动.
该应用程序在转换到下一页的过程中崩溃了大约20%.
编辑2
错误似乎停在了_cache_getImp行(不确定这是大写字母i还是小写字母L).
编辑3
这变得更好.我刚刚下载了Apple的PhotoScroller示例应用程序,看看他们是否以不同的方式解决了问题.嗯,不,他们没有.示例应用程序以与我的方式完全相同的方式崩溃!你必须同时缩放,滚动和转换页面,以使其更容易崩溃,但它也可能发生在它自己也可能需要更长时间才能发生.
我UIPageViewController
在iPad上使用,我需要firstviewController
在第一页和ContentViewController
下一页的横向显示.
如果我设置了NSArray
两个viewControllers
应用程序崩溃,[self.pagviewController setViewController:]
则出现以下异常:
提供的视图控制器(2)的数量与请求的脊椎位置所需的数量(1)不匹配(UIPageViewControllerSpineLocationMin)
以下是代码:
#pragma mark - UIPageViewControllerDataSource Methods
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerBeforeViewController:(UIViewController *)viewController
{
NSUInteger currentIndex = [self.modelArray indexOfObject:[(ContentViewController *)viewController textContents]];
if(currentIndex == 0)
{
return nil;
}
ContentViewController *contentViewController = [[ContentViewController alloc] init];
contentViewController.textContents = [self.modelArray objectAtIndex:currentIndex - 1];
return contentViewController;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerAfterViewController:(UIViewController *)viewController
{
NSUInteger currentIndex = [self.modelArray indexOfObject:[(ContentViewController *)viewController textContents]];
if(currentIndex == self.modelArray.count-1)
{
return nil;
}
ContentViewController …
Run Code Online (Sandbox Code Playgroud) 我试图产生类似于新雅虎天气应用程序中的效果.基本上,每个页面UIPageViewController
都有一个背景图像,当滚动浏览页面视图时,图像的位置只滚动大约一半的速度.我该怎么办?我以为我可以使用某种委托方法UIPageViewController
获取当前偏移量,然后像这样更新图像.唯一的问题是我无论如何都无法判断是否UIPageViewController
正在滚动!有没有办法呢?谢谢!
我最常见的错误是"无法确定滚动的导航方向",我有任何想法可以解决它吗?
这是最后一个Exception Backtrace:
1. CoreFoundation __exceptionPreprocess + 131
2. libobjc.A.dylib _objc_exception_throw + 39
3. CoreFoundation +[NSException raise:format:] + 1
4. Foundation -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 91
5. UIKit __54-[_UIQueuingScrollView _didScrollWithAnimation:force:]_block_invoke + 221
6. UIKit -[_UIQueuingScrollView _didScrollWithAnimation:force:] + 567
7. UIKit -[_UIQueuingScrollView _scrollViewAnimationEnded:finished:] + 73
8. UIKit -[UIAnimator stopAnimation:] + 471
9. UIKit -[UIAnimator(Static) _advanceAnimationsOfType:withTimestamp:] + 285
10. UIKit -[UIAnimator(Static) _LCDHeartbeatCallback:] + 53
11. QuartzCore CA::Display::DisplayLinkItem::dispatch() + 99
12. QuartzCore CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 345
13. …
Run Code Online (Sandbox Code Playgroud) 我想获取pageViewController的当前索引,我不知道如何获取可见页面索引.
func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool,previousViewControllers: [UIViewController],transitionCompleted completed: Bool)
{
// How to get it?
}
Run Code Online (Sandbox Code Playgroud) uiviewcontroller uipagecontrol ios uipageviewcontroller swift
我有一个与XCode 5和iOS 7一起工作得很好的项目,但是当我最近下载XCode 6时,我注意到autolayout出现了一些奇怪的行为.
我有一个故事板,其视图只有一个UIImageView和两个UILabel.使用UiPageViewController加载此视图.UIImageView在视图中水平和垂直居中,并且存在约束,指定两个标签与图像视图的距离.当故事板和自动布局值发生冲突时(例如,在故事板中,一个标签在图像视图上方20个像素但自动布局显示它应该在40像素以上),过去的自动布局值是在加载视图之前成功应用.因此,当视图第一次显示时,一切都在正确的位置.
现在使用iOS 8/XCode 6,我看到视图加载然后事情跳转到他们的最终自动布局位置.在模拟器和真实设备上,这种跳转对于最终用户来说是显而易见的,而且它真的很烦人.有没有办法回到过去的行为?据我所知,没有代码更改导致此问题.
我有以下内容ViewController
:
class PageContentViewController: UIViewController {
var pageIndex: Int
}
Run Code Online (Sandbox Code Playgroud)
我如何pageIndex
从另一个ViewController 访问?
我需要访问pageIndex
此功能:
func pageViewController(pageViewController: UIPageViewController!, viewControllerBeforeViewController viewController: UIViewController!) -> UIViewController! {
//var index: Int
//index = ?
NSUInteger index = ((PageContentViewController*) viewController).pageIndex; // in Swift?
if ((index == 0) || (index == NSNotFound)) {
return nil;
}
index--;
return [self viewControllerAtIndex:index]; // in Swift?
}
Run Code Online (Sandbox Code Playgroud) 我有一个UIPageViewController,当我们向左或向右滑动以翻页时它工作正常.
class ViewController: UIViewController, UIPageViewControllerDataSource {
...
}
Run Code Online (Sandbox Code Playgroud)
现在我打算在页面上提供上一个/下一个按钮,以便通过单击这些按钮来转动页面.
如何触发向左/向右滑动或以编程方式翻页?
这是Swift语言的问题,而不是Objective-C.
我有一个带故事板的应用程序.我正在使用多个带有segue的View Controller,可根据所选项目从表格视图中进行选择.我想要一个页面视图控制器,其中页面将是故事板中的一个或多个视图控制器,甚至重复它们.我正在尝试这样init
的页面视图控制器:.... self.dataSource = self;
UIViewController *initialViewController =[self viewControllerAtIndex:current];
NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];
[self setViewControllers:viewControllers direction:UIPageViewControllerNavigationOrientationHorizontal animated:NO completion:nil];
....
- (UIViewController *)viewControllerAtIndex:(NSUInteger)index
{
if ((descriptions.count == 0) ||
(index >= descriptions.count)) {
return nil;
}
current=index;
// Create a new view controller and pass suitable data.
NSString *language = [[NSLocale preferredLanguages] objectAtIndex:0];
Description *description=[DBCompany getDescriptionById:language descriptionId:[[descriptions objectAtIndex:index] integerValue]];
UIViewController *viewController=nil;
if(description.frame==100){
viewController=[[Company100ViewController alloc] init];
((Company100ViewController*)viewController).companyId = companyId;
}
return viewController;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController …
Run Code Online (Sandbox Code Playgroud) ios ×8
objective-c ×5
iphone ×3
swift ×3
autolayout ×1
debugging ×1
ios7 ×1
uiimage ×1
uikit ×1
uiscrollview ×1
xcode ×1
xcode6 ×1