iOS / Objective C: an extremely simple UIAlertView alternative

Overview

RKDropdownAlert

an extremely simple (and customizeable) alert alternative based on Facebook's app Slingshot, and inspiration from SVProgressHUD (yes, it's just as easy to use as SV).

Updates, Questions, and Requests

Support or twitter <--- I am a very light twitterer, so I wont spam you

Article comparing UIAlertView, SVProgressHUD and RKropdownAlert

https://medium.com/@cwRichardKim/devux-uialertview-alternatives-3a78ab64cbf8

Pod

WAIT! Don't use pods if you want to customize or use the quick and easy [RKDropdownAlert show]

pod 'RKDropdownAlert'

Demo:

[RKDropdownAlert title:@"Hello World" message:@"Tons better than UIAlertView!"];

alt tag

In Action:

first

second

Easy Default Call

[RKDropdownAlert show];

Set the default text, color, size, font, etc so that when you call "show" it pulls up an easy default call

easy

Setup

First, download the file, or create a branch of the repo. Copy the following into your parent controller:

# import "RKDropdownAlert.h"

You will probably want to customize the default call ([RKDropdownAlert show]), as well as other features such as color, the method called when the user taps the view, etc. Look for

//%%% CUSTOMIZE

tags in the RKDropdownAlert.m for methods that you should customize.

Calling the Alert

Use the following variations of title, message, backgroundColor, textColor, and time

+(void)show;
+(void)title:(NSString*)title;
+(void)title:(NSString*)title time:(NSInteger)seconds;
+(void)title:(NSString*)title backgroundColor:(UIColor*)backgroundColor textColor:(UIColor*)textColor;
+(void)title:(NSString*)title backgroundColor:(UIColor*)backgroundColor textColor:(UIColor*)textColor time:(NSInteger)seconds;

+(void)title:(NSString*)title message:(NSString*)message;
+(void)title:(NSString*)title message:(NSString*)message time:(NSInteger)seconds;
+(void)title:(NSString*)title message:(NSString*)message backgroundColor:(UIColor*)backgroundColor textColor:(UIColor*)textColor;
+(void)title:(NSString*)title message:(NSString*)message backgroundColor:(UIColor*)backgroundColor textColor:(UIColor*)textColor time:(NSInteger)seconds;

For example:

[RKDropdownAlert show];

[RKDropdownAlert title:@"this is a title" message:@"this is a one line message"];

[RKDropdownAlert title:@"Hello World" message:@"tons better than UIAlertView" backgroundColor:[UIColor grayColor] textColor:[UIColor whiteColor] time:10];

Touch Up Inside Method

Write your own method for when the user touches the view (default is hide the view)

@interface WhateverClassYouLike : NSObject <RKDropdownAlertDelegate>
@end

@implementation WhateverClassYouLike

-(BOOL)dropdownAlertWasTapped:(RKDropdownAlert*)alert {
	// Handle the tap, then return whether or not the alert should hide.
	return true;
}

@end

alt tag

Areas for Future Improvement / Involvement

  • Improve architecture to maintain single line deployment while also allowing for attribute customization without changing physical code
  • Ability to change layout of text without changing physical code
  • Singleton pattern
  • More rigorous case testing for responsive design (making sure different text lengths still look good)
Comments
  • Add the `RKDropdownAlert` to the current view controller.

    Add the `RKDropdownAlert` to the current view controller.

    If a view controller was presented as modal, it would obscure the RKDropdownAlert from view. Using this method, the alert view is added to the currently visible view controller. Oftentimes, that's still the root view controller (this was tested), but there are some cases where it's a different view controller.

    We're hoping to use RKDropdownAlert in the iOS App for the Storybird (storybird.com), but it's a non-starter for us without this patch.

    opened by rockstar 7
  • Only one dropdown alert displayed at a time

    Only one dropdown alert displayed at a time

    Hello, what do you think about implementing an event listener for if the user touches anywhere outside of the dropdown. For example to prevent overlapping of multiple dropdowns if the user presses a button somewhere on the screen that triggers a new dropdown (they could potentially have tons of dropdowns displaying on the screen if the delay was long enough).

    Thanks for reading!

    • Jared
    opened by jaredreich 4
  • No work in the second page in a navigation

    No work in the second page in a navigation

    if(!self.superview){
        NSEnumerator *frontToBackWindows = [[[UIApplication sharedApplication]windows]reverseObjectEnumerator];
    
        for (UIWindow *window in frontToBackWindows)
            if (window.windowLevel == UIWindowLevelNormal) {
                [window.rootViewController.view addSubview:self];//no work
                [window addSubview:self]; //work
                break;
            }
    }
    

    if in the second page in a navigation ios8.0

    opened by ipoolo 3
  • dropdownAlertWasTapped always called

    dropdownAlertWasTapped always called

    Hi, Thx for this lib, really clean and helpful!

    I'm just facing an issue.. I've set an alert that looks like this:

    [RKDropdownAlert title:@"Notification" message:@"Message" backgroundColor:[UIColor grayColor] textColor:[UIColor whiteColor] time:5 delegate:self];

    and implemented the delegate's method like that:

    - (BOOL)dropdownAlertWasTapped:(RKDropdownAlert *)alert{ [self doSomething]; return YES; }

    - (BOOL)dropdownAlertWasDismissed{ return YES; }

    My problem is: dropdownAlertWasTapped is always called after the 5 seconds time, even when I'm not touching the screen.

    opened by Tibb 1
  • Feature Request: Custom font

    Feature Request: Custom font

    I like that I can customize the alert with a custom background color and text color... but I would also like to be able to give it a custom font. Thanks! :)

    opened by MacieKluting 1
  • Add delegate option so tap can be handled anywhere

    Add delegate option so tap can be handled anywhere

    Developers should not have to modify the package in order to handle the user tapping the alert.

    • Does not break existing code of developers using this package
    • Improves usability and portability by allowing developers to use the Pod
    • Uses the delegate/protocol pattern the same way many built-in Cocoa classes do
    • Allows developers to implement the handler differently in different parts of the app or for different alerts
    opened by andrewbranch 1
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 0
  • Avoid Overlapping RKDropdownAlerts

    Avoid Overlapping RKDropdownAlerts

    add isShowing property and dropdownAlertWasDismissed delegate callback to help avoid overlapping RKDropdownAlerts.

    I've had a need for this when using RKDA to display connection errors on calls and multiple calls are made in quick succession: this leads to a large number of RKDAs to overlap. overlappingrkda

    opened by sternhenri 0
  • Block support

    Block support

    Thanks for writing this. Wondering if you've considered using block callbacks instead of delegate pattern? It would allow the completion handling code to live near where the alerts are shown instead of being handled in a separate method (that might include a large switch statement if you're showing lots of alerts in a single view). I'd be happy to submit a PR if you're interested in exploring further.

    opened by garyjohnson 1
  • crashed when call +[RKDropdownAlert title: message:]

    crashed when call +[RKDropdownAlert title: message:]

    The Fabric has a record of issue:

    
    iPhone5, iOS9.3.1
    Crashed: com.apple.main-thread
    EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000a1b06cf5
    Thread : Crashed: com.apple.main-thread
    0  libobjc.A.dylib                0x2136ba86 objc_msgSend + 5
    1  Foundation                     0x222f779d -[NSObject(NSKeyValueObserverNotification) willChangeValueForKey:] + 276
    2  QuartzCore                     0x241e1251 CA::Layer::set_delegate(objc_object*) + 112
    3  UIKit                          0x26174d95 -[UIView _createLayerWithFrame:] + 592
    4  UIKit                          0x261746e5 UIViewCommonInitWithFrame + 852
    5  UIKit                          0x26174317 -[UIView initWithFrame:] + 130
    6  UIKit                          0x2617bc61 -[UILabel initWithFrame:] + 56
    7  MyApp                  0xcf6af -[RKDropdownAlert initWithFrame:] (RKDropdownAlert.m:56)
    8  MyApp                  0xcfc77 +[RKDropdownAlert alertView] (RKDropdownAlert.m:135)
    9  MyApp                  0xcffab +[RKDropdownAlert title:message:] (RKDropdownAlert.m:174)
    10 MyApp                  0x74847 -[ZZFileViewController p_refreshByConnectStatus] (ZZFileViewController.m:1186)
    11 CoreFoundation                 0x21b53345 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    12 CoreFoundation                 0x21b52d53 _CFXRegistrationPost + 398
    13 CoreFoundation                 0x21b52b29 ___CFXNotificationPost_block_invoke + 40
    14 CoreFoundation                 0x21ba9f63 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1334
    15 CoreFoundation                 0x21ab20eb _CFXNotificationPost + 486
    16 Foundation                     0x222f7b17 -[NSNotificationCenter postNotificationName:object:userInfo:] + 70
    17 UIKit                          0x261fa873 -[UIApplication _stopDeactivatingForReason:] + 1150
    18 UIKit                          0x26413b39 __62-[UIApplication _sceneSettingsPostLifecycleEventDiffInspector]_block_invoke1180 + 104
    19 FrontBoardServices             0x232621a3 __52-[FBSSettingsDiffInspector inspectDiff:withContext:]_block_invoke27 + 158
    20 Foundation                     0x22397e23 __NSIndexSetEnumerate + 430
    21 Foundation                     0x223230f7 -[NSIndexSet enumerateIndexesWithOptions:usingBlock:] + 66
    22 BaseBoard                      0x231f6d17 -[BSSettingsDiff inspectChangesWithBlock:] + 102
    23 FrontBoardServices             0x2325dbe7 -[FBSSettingsDiff inspectOtherChangesWithBlock:] + 94
    24 FrontBoardServices             0x2326200f -[FBSSettingsDiffInspector inspectDiff:withContext:] + 310
    25 UIKit                          0x264142cf __70-[UIApplication scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 170
    26 UIKit                          0x26413f99 -[UIApplication scene:didUpdateWithDiff:transitionContext:completion:] + 644
    27 FrontBoardServices             0x23254c29 __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke_2 + 40
    28 FrontBoardServices             0x2326fbf7 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 18
    29 FrontBoardServices             0x2326faa7 -[FBSSerialQueue _performNext] + 226
    30 FrontBoardServices             0x2326fda5 -[FBSSerialQueue _performNextFromRunLoopSource] + 44
    31 CoreFoundation                 0x21b63a67 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
    32 CoreFoundation                 0x21b63657 __CFRunLoopDoSources0 + 454
    33 CoreFoundation                 0x21b619bf __CFRunLoopRun + 806
    34 CoreFoundation                 0x21ab0289 CFRunLoopRunSpecific + 516
    35 CoreFoundation                 0x21ab007d CFRunLoopRunInMode + 108
    36 GraphicsServices               0x230ccaf9 GSEventRunModal + 160
    37 UIKit                          0x261db2c5 UIApplicationMain + 144
    38 FlashairShare                  0x8abcf main (main.m:14)
    39 libdispatch.dylib              0x2175c873 (Missing)
    

    I check the code, and find it just calls: [RKDropdownAlert title:alertTitle message:alertMsg]; Both the strings are not nil as using NSLocalizedString.
    The Project is using ARC and I have no idea about this EXC_BAD_ACCESS. Could you find something from the crash log?

    opened by scorpiozj 9
  • Two taps required to dismiss RKDropdownAlert

    Two taps required to dismiss RKDropdownAlert

    I seem to have a small bug where I have to tap the dropdown alert twice to dismiss that.

    Is there a reason for that?

    My code is simply :

    [RKDropdownAlert title:message];

    opened by sepandb 1
  • Feature request: Time as Float

    Feature request: Time as Float

    +(void)title:(NSString_)title backgroundColor:(UIColor_)backgroundColor textColor:(UIColor*)textColor time:(NSInteger)seconds;

    I want to use faster or more precise timing for this. How about making another method which takes Float as a parameter?

    I could have done this and sent a pull request but I haven't been using obj-c for a long time. If no one does it I still might.

    opened by goktugyil 1
Releases(0.3.0)
FCAlertView is a Flat Customizable AlertView for iOS (Written in Objective C)

FCAlertView FCAlertView is a Flat Customizable AlertView, written in Objective C Quick Links 1. Swift 2. Installation 3. Example App 4. Adding FCAlert

Nima Tahami 794 Nov 29, 2022
Beautiful animated Login Alert View. Written in Objective-C

UIAlertView - Objective-C Animated Login Alert View written in Swift but ported to Objective-C, which can be used as a UIAlertView or UIAlertControlle

Letovsky 2 Dec 22, 2021
Customizable simple Alert and simple ActionSheet for Swift

SimpleAlert It is simple and easily customizable alert. Can be used as UIAlertController. Appetize's Demo Requirements Swift 5.0 iOS 9.0 or later How

Kyohei Ito 397 Dec 6, 2022
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Introduction Popup Dialog is a simple, customizable popup dialog written in Swift. Features Easy to use API with hardly any boilerplate code Convenien

Orderella Ltd. 3.8k Dec 20, 2022
Simple DropDown Alert View For Any iOS Projects.

⚠️ DEPRECATED, NO LONGER MAINTAINED JDropDownAlert JDropDownALert Simple DropDown Alert View For Any iOS Projects. Usage Top let alert = JDropDown

WonJo 71 Jul 17, 2022
A Simple Toast Library for iOS

PowerplayToastKit Toasts Type Success. Warning Error Info Custom View (Dialog) Example To run the example project, clone the repo, and run pod install

Mithilesh Parmar 18 Jul 2, 2022
A Simple And Minimalist iOS AlertController

HYAlertController HYAlertController is a minimalist alert control, that contains a variety of usage scenarios. It has the same syntax as Apple's UIAle

null 63 Jul 26, 2022
A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

donggyu 5 Jan 26, 2022
A simple style messages/notifications, in Swift.

Demo Example To show notifications use the following code: self.showMessage("Something success", type: .success) To display a notice on a view: view.s

Gesen 704 Dec 17, 2022
Simple UIAlertController builder class in Swift.

Kamagari Simple UIAlertController builder class in Swift. Features AlertBuilder class to simply build UIAlertController by using method chaining UIAle

Kazunobu Tasaka 78 Nov 29, 2022
Lightweight dropdown message bar in Swift. It's simple and beautiful.

SwiftyDrop SwiftyDrop is a lightweight pure Swift simple and beautiful dropdown message. Features Easy to use like: Drop.down("Message") Message field

Morita Naoki 691 Nov 20, 2022
BottomSheet makes it easy to take advantage of the new UISheetPresentationController in SwiftUI with a simple .bottomSheet modifier on existing views.

BottomSheet makes it easy to take advantage of the new UISheetPresentationController in SwiftUI with a simple .bottomSheet modifier on existing views.

Adam Foot 341 Dec 15, 2022
Whisper is a component that will make the task of display messages and in-app notifications simple. It has three different views inside

Description ?? Break the silence of your UI, whispering, shouting or whistling at it. Whisper is a component that will make the task of displaying mes

HyperRedink 3.7k Dec 25, 2022
🌊 - Jelly is a library for animated, non-interactive & interactive viewcontroller transitions and presentations with the focus on a simple and yet flexible API.

Jelly is a library for animated, non-interactive & interactive viewcontroller transitions and presentations with the focus on a simple and yet flexibl

Sebastian Boldt 2.4k Dec 25, 2022
zekunyan 608 Dec 30, 2022
Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)

DOAlertController Simple Alert View written in Swift, which can be used as a UIAlertController replacement. It supports from iOS7! It is simple and ea

Daiki Okumura 406 Sep 5, 2022
😍A simple NoticeBar written by Swift 3, similar with QQ notice view.

NoticeBar ?? A simple NoticeBar written by Swift 3, similar with QQ notice view. ?? ScreenShots Remember: If you want the status bar style change, you

Qiun Cheng 235 Sep 9, 2022
Simple Swift in-app notifications

LNRSimpleNotifications TSMessages is an amazingly powerful in-app notifications library but requires a lot of setup. LNRSimpleNotifications is a simpl

LISNR 203 Nov 20, 2022
AlertView A pop-up framework, Can be simple and convenient to join your project.

RAlertView AlertView A pop-up framework, Can be simple and convenient to join your project. Warning content Installation Depend on the project Masonry

杜耀辉 71 Aug 12, 2022