Build Internet has a brand new theme, and that's only the beginning. Read the full story or hide this bar

YRDropdownView – A Polite UIAlertView Alternative for iOS

YRDropdownView is an iOS library for displaying stylish alerts, warnings, and errors

UIKit’s Shortcomings

From day one, iOS developers have been struggling to alert users about simple warnings and errors that may not interrupt the flow of the app. Popping up UIAlertViews requires the user to click a button to move along, which wasn’t quite necessary for warnings that merely limit useability. Adding a UILabel somewhere on the screen isn’t consistent and doesn’t always look great.

Maybe you just have some more information you want to inform your user about. Simply adding it to the screen is sufficient, but what if your information is added off screen? How does your user know it has appeared? TweetBot found a great solution to that. By overlaying a simple panel, with an icon, title, and message, the flow of the app is uninterrupted, yet informs the user in a concise manner.

Tweetbot Alert Example


Imitation Is The Greatest Form Of Flattery

YRDropdownView

YRDropdownView is a simple and versitile class that will increase the visibility of information relating to your app in a stylish way. YRDropdownView draws inspiration from such libraries like MKInfoPanel, MBProgressHUD, and DSActivityView and fills the gaps where these classes left off.

Usage

herever you want to use YRDropdownView, import the header file as follows:

#import "YRDropdownView.h"

Basic

You can create your dropdown by calling the singleton method:

[YRDropdownView showDropdownInView:self.view
                             title:@"Warning"
                            detail:@"Danger Will Robinson. You cannot do that."];

By default, calling the above method will only dismiss when clicked on. To dismiss manually in your code, call:

[YRDropdownView hideDropdownInView:self.view];

Customizing

There are many different ways to customize the alert by calling different singleton methods:

+ (YRDropdownView *)showDropdownInView:(UIView *)view
                                 title:(NSString *)title;

+ (YRDropdownView *)showDropdownInView:(UIView *)view
                                 title:(NSString *)title
                                detail:(NSString *)detail;

+ (YRDropdownView *)showDropdownInView:(UIView *)view
                                 title:(NSString *)title
                                detail:(NSString *)detail
                              animated:(BOOL)animated;

+ (YRDropdownView *)showDropdownInView:(UIView *)view
                                 title:(NSString *)title
                                detail:(NSString *)detail
                                 image:(UIImage *)image
                              animated:(BOOL)animated;

+ (YRDropdownView *)showDropdownInView:(UIView *)view
                                 title:(NSString *)title
                                detail:(NSString *)detail
                                 image:(UIImage *)image
                              animated:(BOOL)animated
                             hideAfter:(float)delay;

+ (BOOL)hideDropdownInView:(UIView *)view;
+ (BOOL)hideDropdownInView:(UIView *)view animated:(BOOL)animated;

+ (YRDropdownView *)showDropdownInWindow:(UIWindow *)window
                                   title:(NSString *)title;

+ (YRDropdownView *)showDropdownInWindow:(UIWindow *)window
                                   title:(NSString *)title
                                  detail:(NSString *)detail;

+ (YRDropdownView *)showDropdownInWindow:(UIWindow *)window
                                   title:(NSString *)title
                                  detail:(NSString *)detail
                                animated:(BOOL)animated;

+ (YRDropdownView *)showDropdownInWindow:(UIWindow *)window
                                   title:(NSString *)title
                                  detail:(NSString *)detail
                                   image:(UIImage *)image
                                animated:(BOOL)animated;

+ (YRDropdownView *)showDropdownInWindow:(UIWindow *)window
                                   title:(NSString *)title
                                  detail:(NSString *)detail
                                   image:(UIImage *)image
                                animated:(BOOL)animated
                               hideAfter:(float)delay;

+ (BOOL)hideDropdownInWindow:(UIWindow *)window;
+ (BOOL)hideDropdownInWindow:(UIWindow *)window animated:(BOOL)animated;

Notes

Label and Background Customization

Currently, the title and detail labels, as well as the yellow background, are static for all dropdowns. Customizing these features are a TODO for this project.

Automatic Reference Counting (ARC) support

ARC support has been neglected in part for now. Your contributions are more than welcome, however. If you want to use YRDropdownView in an ARC project, just add the add the compiler flag:

-fno-objc-arc

to all YRDropdownView files in your project.

Project on GitHub

For the cutting edge releases and outstanding issues, we’ve set up a GitHub repository to keep everything in order. Feel free to post any code related issues or contributions there in addition to in the comments below. We’ll also be doing minor releases there from time to time without making full blog posts. Enjoy!

Wordpress.com stats not installed! Posted Wednesday, February 1st, 2012 / Back to Top

I this post. Tweet
SPONSOR

7 Comments 5 Mentions

  1. 7OOOF.net Author Editor

    Well Done… Thanks

    February 2, 2012 · Reply

  2. kostas mouzakitis Author Editor

    Continue the good job :)

    February 19, 2012 · Reply

  3. fabir Author Editor

    very helpful thanks

    February 26, 2012 · Reply

  4. fabir Author Editor

    best web site ever…
    thanks man

    February 26, 2012 · Reply

  5. شات صوتي Author Editor

    You are great and thank for you articles

    March 6, 2012 · Reply

  6. Crane Boom Truck Author Editor

    this was so cool! i love your articles

    March 20, 2012 · Reply

  7. bdahfdsai Author Editor

    this was so cool! i love your articles

    May 6, 2012 · Reply

 

Join the Conversation

Back to Top / Comment RSS

2012 Build Internet. Created by One Mighty Roar. Icons by Komodo Media. Back to Top