标签: uiscrollviewdelegate

UIScrollView检测捏拉变焦结束

UIScrollView捏缩小超过其最小缩放限制并且即将动画回来时,我正试图得到通知,但我发现它非常困难.有没有办法可以delegate单独使用方法或者我是否需要覆盖UIScrollView's触摸处理?

uiscrollview uiscrollviewdelegate ios

6
推荐指数
2
解决办法
5835
查看次数

无法专门化非泛型类型'UIViewController'

我正在尝试使用UIScrollViewDelegate:

class ViewController: UIViewController <UIScrollViewDelegate> {}
Run Code Online (Sandbox Code Playgroud)

但我有错误: Cannot specialize non-generic type 'UIViewController'

uiscrollviewdelegate ios

6
推荐指数
1
解决办法
2633
查看次数

在tvOS上的UIScrollView

问题很简单,如何在tvOS中的UIScrollView中启用滚动和缩放?

我从iOS尝试了相同的初始化代码,并返回了focusedView var 的scrollview,但是当我触摸遥控器时没有任何反应.

此外,我试图将另一个自定义UIPanGestureRecognizer添加到scrollview,实际上它工作,但我不想用自定义代码处理平移,只是使用像iOS一样的平移行为.

让我知道,谢谢.

uiscrollview uiscrollviewdelegate uipangesturerecognizer uipinchgesturerecognizer tvos

6
推荐指数
1
解决办法
3914
查看次数

检测 UIScrollView 中的突然滚动停止

我想知道如何使用 来UIScrollViewDelegate检测滚动视图何时突然停止移动,因为用户在快速平移启动动量后触摸并按住了屏幕。

scrollViewDidEndDecelerating:仅当用户抬起手指时,该方法才会在上述情况下触发。但是,如果用户在滚动视图动量期间点击并按住,则此方法不会触发(直到他们抬起手指)。当用户触摸时滚动视图停止时,是否有办法拦截此行为?

uiscrollview uiscrollviewdelegate ios

5
推荐指数
1
解决办法
1639
查看次数

观察滚动视图的"拖动"属性但未收到任何通知

我有一个自定义UIView添加为subViewa UIScrollView,我希望UIView每当UIScrollView滚动时自动重新定位.除了观察UIScrollView's contentOffset属性(工作正常),我还需要观察它的dragging属性:

[scrollView addObserver:self 
             forKeyPath:@"dragging" 
                options:NSKeyValueObservingOptionNew 
                context:NULL];
Run Code Online (Sandbox Code Playgroud)

但是在observeValueForKeyPath:ofObject:change:context方法上,我没有收到任何NSNotification改变dragging财产的信息,这里有什么问题?谢谢.

更新

因为我会重用这个自定义UIViewUIViewControllers,我想自定义视图自己能够处理的重新定位逻辑,而不是重复在每一个重新定位的逻辑UIViewController's UIScrollViewDelegate方法(如scrollViewDidScroll东西).

cocoa-touch objective-c key-value-observing uiscrollview uiscrollviewdelegate

5
推荐指数
1
解决办法
1535
查看次数

水平视差滚动UIScrollView iOS

我正在尝试在分页滚动视图上实现水平视差,这使得一个视图看起来在x方向上前进得更快但在相同点上"着陆"(例如,说(0,0)).这是我的常规设置/视图层次结构:

  • (透明卷轴,拦截/传递滚动事件)
  • (物体叠加,我想在x方向上移动1.2倍,但不超过它的"着陆点")
  • (我希望在x方向以1.0x的速度移动的另一个叠加)

我知道它必须做一些修改contentOffset的事情,我让我的代表都进行了设置,这样他们就能以1x的速度向相同的方向移动......任何有关解决方案的提示?

uiscrollview uiview uiscrollviewdelegate ios parallax

5
推荐指数
1
解决办法
3722
查看次数

如何在uipageviewcontroller中放大或缩小?

我有一个uipageviewcontroller并在uipageviewcontroller中设置了一个名为contentviewcontroller的子视图控制器.

thePageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation: UIPageViewControllerNavigationOrientationHorizontal options:nil];

    thePageViewController.delegate = self;
    thePageViewController.dataSource = self;

    thePageViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    contentViewController = [[HBDocumentChildViewController alloc] initWithPDF:PDFDocument];
    contentViewController.page = [modelArray objectAtIndex:0];
    NSArray *viewControllers = [NSArray arrayWithObject:contentViewController];
    [thePageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

    [self addChildViewController:thePageViewController];
    [self.view addSubview:thePageViewController.view];
    thePageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    [thePageViewController didMoveToParentViewController:self];
    self.view.gestureRecognizers = thePageViewController.gestureRecognizers;
    self.view.backgroundColor = [UIColor underPageBackgroundColor];
Run Code Online (Sandbox Code Playgroud)

我已经完成了借助滚动视图类(pdfScrollView)将pdf文件加载到uipageviewcontroller中的页面.followig是uipageviewcontroller的内容类并初始化uiscrollview类.

#import "HBDocumentChildViewController.h"

@interface HBDocumentChildViewController ()<UIWebViewDelegate>
{
    int currentPage;
    NSString*localPath;
}

@end

@implementation HBDocumentChildViewController

#pragma mark - View lifecycle

- (void)viewDidLoad
{ …
Run Code Online (Sandbox Code Playgroud)

uiscrollview uiviewcontroller uiscrollviewdelegate ios uipageviewcontroller

5
推荐指数
2
解决办法
4674
查看次数

当headerview到达顶部时,使用内部tableview滚动外部tableview,反之亦然

我意识到这个问题的变化已被问到,但是我无法将这些点连接成一个连贯的解决方案来解决我的问题.所以这是我的情景:

我有一个UITableView有2个部分.第1节没有标题视图和1个单元格.第2节有一个标题视图(它是浮动的,因为它是普通表视图的默认行为)和1个单元格.这个单独的第1部分单元格具有3页的水平分页滚动视图.每个页面都是一个tableview.这听起来有点疯狂,但它完全合法且完全合情合理.我的方案是用户个人资料屏幕.第1节的单元格是用户的生物.第2节的标题是一个分页菜单,显示了三个菜单选项.寻呼机有三个用于用户发布,跟随和发布的内容的表视图.

在此输入图像描述

问题是,当用户滚动寻呼机中的任何内部表视图时,我希望外部的表视图滚动,直到生物被滚动到屏幕上,并且节标题点击视图控制器的导航栏.然后我希望内部scrollview接管滚动.

我一直在玩这些UIGestureRecognizerDelegate方法的组合:shouldRecognizeSimultaneouslyWithGestureRecognizer&shouldRequireFailureOfGestureRecognizer.我可以同时滚动tableviews(顺便说一句,顺便说一下,这不是很糟糕,但绝对不是我想要的行为)或只是在内部或外部tableview上滚动.我希望能够使用这个问题来解决这个问题,UIGestureRecognizerDelegate因为我的直觉告诉我解决方案不需要涉及任何委托和覆盖contentOffsets使用等等UIScrollViewDelegate方法scrollViewDidScroll:.但也许我错了,我将不得不走那条路.

我以为在扔掉之前我会把它扔到那里.非常感谢任何帮助!

uitableview uiscrollview uiscrollviewdelegate uigesturerecognizer swift

5
推荐指数
0
解决办法
335
查看次数

将scrollViewWillEndDrag中的targetContentOffset更新为错误方向的值不会激活动画

我要在中设置一个新值,以targetContentOffsetscrollViewWillEndDragging(_:withVelocity:targetContentOffset:)中创建自定义分页解决方案UITableView。设置targetContentOffset与速度指向相同的滚动方向的坐标时,它将按预期工作。

但是,当沿速度的相反方向“向后”捕捉时,它会立即“向后捕捉”而没有动画。这看起来很糟糕。关于如何解决此问题的任何想法。

func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
    // a lot of caluculations to detemine where to "snap scroll" to
    if shouldSnapScrollUpFromSpeed || shouldSnapScrollUpFromDistance {
        targetContentOffset.pointee.y = -scrollView.frame.height
    } else if shouldSnapScrollDownFromSpeed || shouldSnapScrollDownFromDistance {
        targetContentOffset.pointee.y = -detailViewHeaderHeight
    }
}
Run Code Online (Sandbox Code Playgroud)

我可以有力地计算出何时会出现“错误”,并可能使用另一种“快照滚动”的方式。关于如何执行此操作或targetContentOffset.pointee.y正常解决问题的任何建议?

cocoa-touch uitableview uiscrollview uiscrollviewdelegate

5
推荐指数
1
解决办法
646
查看次数

约束更改后第一次 UITableView 点击不起作用

重要提示:我的问题不是我正在实施didDeelectRowAt而不是didSelectRowAt. 已经检查过:)

我有一个UITableView以模态呈现的视图控制器显示在屏幕的一部分上。当用户拖动它时,它会调整到全屏并返回到某个定义的最小高度。我通过实现以下方法来做到这一点UIScrollViewDelegate

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    guard !scrollView.isDecelerating else { return }

    let contentOffset = scrollView.contentOffset.y
    if tableViewHeightConstraint.constant < view.frame.height && contentOffset > 0.0 {
        tableViewHeightConstraint.constant = min(contentOffset + tableViewHeightConstraint.constant, view.frame.height)
        scrollView.contentOffset.y = 0.0
        return
    }

    if tableViewHeightConstraint.constant > minViewHeight && contentOffset < 0.0 {
        tableViewHeightConstraint.constant = max(tableViewHeightConstraint.constant + contentOffset, minViewHeight)
        scrollView.contentOffset.y = 0.0
    }
}

func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
    // Here I …
Run Code Online (Sandbox Code Playgroud)

uitableview uiscrollview uiscrollviewdelegate ios swift

5
推荐指数
1
解决办法
1057
查看次数