- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在导航 Controller 中有一个 View 。
然后我向该 View 添加一个 subview 并偏移其原点高度,使其仅覆盖屏幕的一半(另一半溢出屏幕底部)。然后我希望能够向上拖动此 View ,但当它到达导航栏底部时它会停止。
我正在使用 UIPanGestureRecognizer
来处理 View 的拖动,这工作正常,但它似乎不会在边界处停止。
这是我正在使用的代码:
bottomNavbarY = UIApplication.sharedApplication().statusBarFrame.size.height + self.navigationController!.navigationBar.frame.size.height
view.addSubview(pullover.view)
pullover.view.frame.origin.y = pulloverOffset
var animator = UIDynamicAnimator(referenceView: view)
var collision = UICollisionBehavior(items: [pullover.view])
collision.translatesReferenceBoundsIntoBoundary = true
collision.addBoundaryWithIdentifier("upper", fromPoint: CGPointMake(0, bottomNavbarY), toPoint: CGPointMake(UIScreen.mainScreen().bounds.size.width, bottomNavbarY))
animator.addBehavior(collision)
但是,当我向上拖动覆盖 View 时,它不会与任何边界交互,它只是直接穿过。我究竟做错了什么?是否可以使用边界来阻止用户以这种方式拖动的 View ?
最佳答案
when I drag the covering view up it never interacts with any boundary
您误解了此功能。碰撞边界用于 UIKit Dynamics 负责移动 View 的情况。拖动是指用户负责移动 View 。如果您希望拖动在某个点停止,则由您在手势识别器处理程序中考虑 View 的位置,如果您不希望它移动,则不要移动 View 。
关于ios - UICollisionBehavior 边界不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31326643/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!