Awesome
Purpose
A simple class that enables anything that can be scrolled to be scrolled by bumping the device in a certain direction. Inspired by Amazon's Fire Phone ability to scroll without dragging.
Supported OS & SDK Versions
This class was designed to work with and tested on iOS 7.1, but it might quite well work with earlier versions also. It requires ARC.
Installation
To use class in an app, just drag the MSMotionScroller class files (demo files and assets are not needed) into your project and add the CoreMotion framework. You can use CocoaPods, too. Please refer to this website for more details.
How to Use
First, create an internal variable inside the desired view controller.
MSMotionScroller *motionScroll;
On the viewDidLoad method, simply instanciate the internal variable and assign its delegate.
motionScroll = [[MSMotionScroller alloc]init];
motionScroll.delegate = self;
MSMotionScroller defines a simple delegate that is fired when a motion is captured, by implementing the <code> didMeanToScroll:direction</code> method.
- (void)didMeanToScroll:(MSScrollMotionDirection)direction {
switch (direction) {
case MSScrollMotionDirectionUp:
// DID MEAN TO SCROLL UP
break;
case MSScrollMotionDirectionDown:
// DID MEAN TO SCROLL DOWN
break;
case MSScrollMotionDirectionLeft:
// DID MEAN TO SCROLL LEFT
break;
case MSScrollMotionDirectionRight:
// DID MEAN TO SCROLL RIGHT
break;
}
}
Properties
MSMotionScroller implements a property to define the bump sensibility, defaults to 0.25.
@property CGFloat sensibility;
Another property is used to pause the capture for bumps, if needed.
@property BOOL pause;
Protocols
This class implements a delegate method that gets fired when a bump is detected.
- (void)didMeanToScroll:(MSScrollMotionDirection)direction;
Example Project
Check out the provided example to see how MSMotionScroller is used to scroll a table view and open a sliding menu.
Contribute!
If you wish to contribute please feel free to contact me. I'd love have you onboard!