GithubHelp home page GithubHelp logo

cwrichardkim / rkdropdownalert Goto Github PK

View Code? Open in Web Editor NEW
1.5K 44.0 143.0 335 KB

iOS / Objective C: an extremely simple UIAlertView alternative

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

License: MIT License

Ruby 19.55% Objective-C 80.45%

rkdropdownalert's Introduction

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)

rkdropdownalert's People

Contributors

andrewbranch avatar bryant1410 avatar chakming avatar cwrichardkim avatar nathankot avatar rockstar avatar sternhenri avatar takeshig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rkdropdownalert's Issues

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.

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

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.

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?

Feature request: Close button

Hey,

could you maybe add a (optional) close button to the right of the notification, or a swipe gesture similar to normal notifications in iOS, to dismiss the notification, without toggling the action related to the viewWasTapped?

Thanks!

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! :)

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

wrong cocoapod

your cocoapod spec on cocoapod.org is downloading RKNotificationHub that is a code that has nothing to do with notifications.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.