This sample demonstrates the use of the BDHoverViewController. BDHoverViewController provides a modal view with shadow, that enables you to show the user that an activity such as internet access or long task is ongoing and that interacting with the user interface is not possible. There are four different versions of the hoverView:
- Exclusive Touch where only a UIView with alpha of 0.1 is shown.
- An exclusive touch UIView with a UIActivityIndicator
- An exclusive tough UIView with a UIActivityIndicator and UILabel for status.
- An exclusive touch UIView with a UIActivityIndicator, UILabel for status, and a UIProgressView
- An exclusive touch UIView that displays a UIImage that you supply.
BDHoverViewController makes extensive use of blocks in order to build the animations for transitions from one hoverView style to the other. The use of NSMutableArray and blocks allow the building of the animations on the fly.
Notes: As of 10/14/2011, BDHoverview has been converted to Automatic Reference Counting and will only work on iOS5 and greater.
Usage Adding the hoverview at runtime is easy.
- First create an instance of the BDHoverview as follows:
hoverViewController_=[[BDHoverViewController alloc] initWithHoverStatusStyle:BDHoverViewStatusExclusiveTouchStyle
options:BDHoverViewControllerOptionsShowBevel];
hoverViewController_.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
self.window.rootViewController.modalPresentationStyle=UIModalPresentationCurrentContext;
[self.window.rootViewController presentModalViewController:hoverViewController_ animated:YES];
The initializers make use of the BDHoverViewControllerOptions type that set specific options such as whether or not a bevel (BDHoverViewControllerOptionsShowBevel)is show or a border (BDHoverViewControllerOptionsShowBorder) is drawn around the BDHoverView.
The BDHoverViewController adheres to the BDStatusUpdateProtocol. Therefore it will respond to the following update methods: To update just the UIProgressView use: -(void)updateHoverViewProgressWithProgressValue:(float)progress. Even if the BDHoverViewStatusActivityProgressStyle style is not being shown, the progressValue will be saved. This allows the progressView to be animated correctly, if and when you do choose to animate to the BDHoverViewStatusActivityProgressStyle. The usage is as follows.
[hoverViewController_ updateHoverViewProgressWithProgressValue: 0.5f];
To update just the UILabel for status use: -(void)updateHoverViewStatus:(NSString *)status. Just like the with the UIProgressView above, this can be used even when the statusLabel is not visible to ensure that the status is available for when you choose to animate to a Hover View Status style that includes it. Here is the usage:
[hoverViewController_ updateHoverViewStatus: @"Contacting App Store..."];
The status label and progress ui can be update at the same time using: -(void)updateHoverViewStatus:(NSString *)status progressValue:(float)progress. Here is the usage.
[hoverViewController_ updateHoverViewStatus: @"Updating Files..." progressValue: 0.75f];
Animating from one Hover View Style to another is simple using this method: -(void)animateToHoverViewStatusStyle:(BDHoverViewStatusStyle)hoverViewStatusStyle completion:(void (^)(BOOL finished))completion. The completion block is useful for any other clean up code that you may want to execute.
[hoverViewController_ animateToHoverViewStyle:BDHoverViewStatusActivityProgressStyle
completion:^(BOOL finished){
NSLog(@"animation finished");
}];
The Activity only style looks like this:
The Activity with Status Label style looks like this:
The Activity, Status, and Progress style looks like this:
The Alert Image Style looks like this:
License
The below license is the new BSD license with the OSI recommended personalizations. http://www.opensource.org/licenses/bsd-license.php
Copyright (C) 2011 Big Diggy SW. All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Tim Taylor nor Big Diggy SW may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY Big Diggy SW "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.