Questions tagged [uicollisionbehavior]

A collision behavior confers, to a specified array of dynamic items, the ability of those items to engage in collisions with each other and with the behavior’s specified boundaries. A collision behavior also specifies some characteristics of its items’ collisions, with other characteristics optionally specified by a UIDynamicItemBehavior object.

A collision behavior confers, to a specified array of dynamic items, the ability of those items to engage in collisions with each other and with the behavior’s specified boundaries. A collision behavior also specifies some characteristics of its items’ collisions, with other characteristics optionally specified by a UIDynamicItemBehavior object.

A dynamic item is any iOS or custom object that conforms to the UIDynamicItem protocol. The UIView and UICollectionViewLayoutAttributes classes implement this protocol starting in iOS 7.0. You can use a custom object as a dynamic item for such purposes as reacting to rotation or position changes computed by a dynamic animator—an instance of the UIDynamicAnimator class.

Click Here for class reference.

38 questions
18
votes
1 answer

UICollisionBehavior - views pass through boundaries

As part of implementing a UICollisionBehaviour I set up boundaries for the screen edge. I then added some views and finally attached a UIPanGestureRecognizer to one of them. Now I can push around the smaller views with my draggable…
RickiG
  • 11,380
  • 13
  • 81
  • 120
9
votes
3 answers

UIKit Dynamics UICollisionBehavior collision without bounce

I have a view whose boundaries are set up for collisions (setTranslatesReferenceBoundsIntoBoundaryWithInsets) and a subview setup with gravity so that it can collide against the superview bounds. I'm trying to make the collision 0% bouncy, but I…
7
votes
3 answers

Setting collision bounding path of a UIView in iOS 9

In iOS 9 Apple introduced the collisionBoundsType to UIKit-Dynamics. I have no issue when setting this UIDynamicItemCollisionBoundsTypeRectangle or when I set this to UIDynamicItemCollisionBoundsTypeEllipse. The screenshot below is from a game I am…
Wyetro
  • 8,439
  • 9
  • 46
  • 64
5
votes
3 answers

UIDynamics and Device Rotation

If I add any kind of UIDynamicBehavior to my views, it completely breaks things when the device is rotated. Here's what it is in portrait (displaying correctly): And here it is in landscape, all broke: I don't believe it's an autolayout issue…
swilliams
  • 48,060
  • 27
  • 100
  • 130
4
votes
1 answer

How would I best use UICollisionBehavior to detect when a view is no longer on screen at all?

I'm trying to use UICollisionBehavior in UIKit Dynamics to figure out when a view that I've thrown off screen (using UIAttachmentBehavior and UIPushBehavior) is actually fully off screen. I'm finding it complicated because I'm not able to track it…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
3
votes
0 answers

What is the "reference system"?

The documentation for the iOS instance property UICollisionBehavior translatesReferenceBoundsIntoBoundary has the description "Specifies whether a boundary based on the reference system is active." What is the reference system? I don't understand…
hlp
  • 1,047
  • 1
  • 9
  • 12
3
votes
1 answer

UICollisionBehavior with iOS9 seems to stop 1.5 points away from boundary: My bug or Apple's?

In my app, I use UIKit Dynamics including a UICollisionBehavior to have a menu bounce when it opens and when it closes. The code I'm using for this is below. This has been working fine for iOS8. With iOS9 (including iOS9.1 beta 2 just released),…
Chris Prince
  • 7,288
  • 2
  • 48
  • 66
3
votes
1 answer

UICollisionBehavior boundary not working

I've got a view within a navigation controller. I am then adding a subview to this view and offsetting its origin height so that it covers only half the screen (with the other half overflowing off out the bottom of the screen). I want to be able to…
myles
  • 1,681
  • 1
  • 15
  • 27
3
votes
0 answers

Adding Gravity behavior to multiple objects in Swift

I am building a game in which there are lots of square blocks floating around the screen, bouncing off each other, walls, etc until they get destroyed. Currently, I have a master UIGravityBehavior and I add each square (a UIView class called…
Jeremy Toeman
  • 81
  • 1
  • 1
  • 7
3
votes
1 answer

UICollisionBehavior - custom shape for UIView collision

I'm trying to figure out how to use UIKit Dynamics to successfully collide two UIViews which have custom boundary shapes. The most basic example I can think of to explain my question is to have two circles collide (taking in to account their round…
Adam Carter
  • 4,741
  • 5
  • 42
  • 103
3
votes
1 answer

How do I draw a circle UIView that acts like one with UICollisionBehavior?

In my app, I'm currently drawing a basic view, and then I'm trying to round it's corners using a CAShapeLayer, but the UICollisionBehavior still reacts like it's a square that is drawn. Here's an example of my code UIBezierPath *path =…
Justin Cabral
  • 565
  • 1
  • 6
  • 20
3
votes
1 answer

Change bounds of UIView and have UICollisionBehavior react to it

Is it possible to change the bounds of a UIView (which is attached to some other UIViews using UIAttachmentBehaviors) and have the UICollisionBehavior in combination with the UIAttachmentBehavior respond to it (like the sample movie here:…
Tom Nys
  • 579
  • 6
  • 13
2
votes
1 answer

UICollisionBehaviorDelegate methods not called

I worked on an app and implemented collision detection using UIKitDynamics. Collision detection is working. But somehow the UICollisionBehaviorDelegate methods are not called. No warnings or errors are shown. I created an example project to…
user610246
  • 732
  • 1
  • 7
  • 11
2
votes
1 answer

UICollisions in Swift

I'm required to make a Breakout app in a Single-View Application in the Swift language. However, I'm having trouble getting the "ball" to respond to hitting the barrier. Additionally, I'm having trouble getting the barrier to disappear after it is…
Mark Young
  • 21
  • 2
2
votes
1 answer

UICollisionBehavior treats open path as closed?

If I define an open UIBezierPath and set it as a collision boundary: _containerPath = [UIBezierPath bezierPathWithArcCenter:center radius:radius …
Phil Mitchell
  • 699
  • 8
  • 25
1
2 3