Coder Social home page Coder Social logo

regexident / dlalertview Goto Github PK

View Code? Open in Web Editor NEW
284.0 11.0 37.0 2.06 MB

UIAlertView replacement that can embed custom content views, is fully themable and let's you use a delegate and/or blocks.

License: Other

Objective-C 98.38% Ruby 1.62%
uialertview theme objective-c

dlalertview's Introduction

DLAlertView No Maintenance Intended

DLAlertView is an API-compatible UIAlertView replacement that can embed custom content views, is fully themable and let's you use a delegate and/or blocks.

Preview

Demo Animation

Features

  • Same API as UIAlertView (+ much, much more!).
  • Use delegates and/or blocks!
  • Animations that match UIAlertView in iOS 7.
  • Default look that matches UIAlertView in iOS 7.
  • Any number of buttons per alert (1..n).
  • Any number of textfields per alert (0..n).
  • Optional custom content view.
  • Change title/message/contentView while shown.
  • Add textfields while shown.
  • Add buttons while shown.
  • Apply custom themes to your individual alerts.
  • Apply individual themes to your individual textfields.
  • Apply individual themes to your individual buttons.
  • Change themes of alert/textfields/buttons while shown.
  • Crossfade between themes.

Installation

Just copy the files in "DLAlertView/Classes/..." into your project.

Alternatively you can install DLAlertView into your project with CocoaPods.
Just add it to your Podfile: pod 'DLAlertView'

Usage

See DLAVAlertView.h for the complete API.

Example usage

DLAVAlertView *alertView = [[DLAVAlertView alloc] initWithTitle:@"Click OK!" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
		[alertView showWithCompletion:^(DLAVAlertView *alertView, NSInteger buttonIndex) {
			NSLog(@"Clicked button '%@' at index: %ld", [alertView buttonTitleAtIndex:buttonIndex], (long)buttonIndex);
		}];

Demos

DLAlertView contains a demo app giving you a quick overview of many of its features.

ARC

DLAlertView uses automatic reference counting (ARC).

Dependencies

None.

Requirements.

iOS 5.1+

Creator

Vincent Esche (@regexident)

License

DLAlertView is available under a modified BSD-3 clause license with the additional requirement of attribution. (DLAlertView further more includes code by Alexander Jarvis, licensed under the MIT license.) See the LICENSE file for more info.

dlalertview's People

Contributors

adrum avatar jeremybower avatar mantas avatar markwpiper avatar nschum avatar regexident avatar seviu avatar sferrini avatar shukuyen avatar zwf 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

dlalertview's Issues

DLAlertView is causing my viewDidLoaded method to be called twice

Hello guys, I've been using your alert, and it's really great!! It allowed me to match my app style in all the UI, so thanks for that.

Regarding this issue, I'm opening it because I'm experiencing a pretty weird situation in which an instance of MFMailComposeViewController can be presented but it's view is never visible, because the presenting UIViewController _viewDidLoad_ method is called twice.

To clarify it a bit, here is a summary of the situation:

  1. I have a UIViewController in which I have an alert as following:
           @property (nonatomic, strong)   DLAVAlertView *compressionAlertView;
  1. I call the alert opening logic as following:
[self.compressionAlertView showWithCompletion:^(DLAVAlertView *alertView, NSInteger buttonIndex){
                switch (buttonIndex) {
                    case 0:
                        [self sharePhoto:photo withCompressionRate:1];
                        break;
                    case 1:
                        [self sharePhoto:photo withCompressionRate:0.5];
                        break;
                    case 2:
                        [self sharePhoto:photo withCompressionRate:0.25];
                        break;
                    default:
                        break;
                }}];
  1. In the share photo method I do the following:
- (void)sharePhoto:(WMMPhoto *)photo withCompressionRate:(CGFloat)compression
{
    if ([MFMailComposeViewController canSendMail]) {
           // some code to set up email fields ...
           [self presentViewController:mailComposer animated:YES completion:nil];
   }
}

The thing is that the first time I want to share a photo my UIViewController viewDidLoad method is called after DLAVAlertViewController executes the following code. At the time that the MFMailComposer if presented and that's how I ended up in a situation in which my mailComposer is presented, but its not visible in my view hierarchy.

- (void)removeAlertView:(DLAVAlertView *)alertView {
    [alertView removeFromSuperview];
    [self.alertViews removeObject:alertView];
    DLAVAlertView *previousAlertView = [self.alertViews lastObject];

    if (previousAlertView) {
        [self.view addSubview:previousAlertView];
        [previousAlertView unhideWithCompletion:nil];
        self.currentAlertView = previousAlertView;
    }

    if (!self.alertViews.count) {
        [self hideBackgroundViewWithCompletion:^(BOOL finished) {
            self.alertWindow.hidden = YES;
            [self.mainWindow makeKeyAndVisible];
        }];
    }
}

If I remove * [self.mainWindow makeKeyAndVisible];* and that's fixed the problem, I can present MFMailComposeViewController without any problem.
But I would like to fully understand why closing the alertView and trying to present a mailComposer could be causing this problem.

If you 'd be able to explain my behaviour a bit further, or the way in which your alert view manage the UIWindow and why it'd be causing the viewDidLoad method to be called twice I'd really appreciate it.

At the moment I needed to remove [self.mainWindow makeKeyAndVisible]; to fix the bug, but I'd like to be sure what are the consequences of doing this.

AlertView rotation in iOS 8

So when I run the demo project in Xcode 6 GM, the AlertView freezes after rotation when an AlertView is presented.

Do you know what's going on?

Default button boldness and ordering inconsistencies.

Hi, great project, I'm using it in a project now where I need to customise an alert.

Just a note - you have made this as close as possible to the UIAlertView API, but there's a few display inconsistencies.

The following example shows how the first other button is bolded in UIKit.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert"
                                                    message:nil
                                                   delegate:nil
                                          cancelButtonTitle:@"Cancel"
                                          otherButtonTitles:@"Done", nil];

screen shot 2014-05-14 at 10 32 50

Whereas in DLAlertView

DLAVAlertView *alertView = [[DLAVAlertView alloc] initWithTitle:@"Alert"
                                                            message:nil
                                                           delegate:nil
                                                  cancelButtonTitle:@"Cancel"
                                                  otherButtonTitles:@"Done", nil];
    [alertView show];

screen shot 2014-05-14 at 10 34 36

Also the Cancel button shows at the bottom (bolded) in UIKit, and the top in DLAlertView.

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert"
                                                    message:nil
                                                   delegate:nil
                                          cancelButtonTitle:@"Cancel"
                                          otherButtonTitles:@"One", @"Two", nil];

    [alert show];

screen shot 2014-05-14 at 10 37 03

DLAVAlertView *alertView = [[DLAVAlertView alloc] initWithTitle:@"Alert"
                                                            message:nil
                                                           delegate:nil
                                                  cancelButtonTitle:@"Cancel"
                                                  otherButtonTitles:@"One", @"Two", nil];
    [alertView show];

screen shot 2014-05-14 at 10 37 37

Is this an oversight? Thanks

Trouble adding to project

Per your instructions, I copied all the files in the Classes folder into my project. However, when attempting to build I receive a myriad of errors (about 48) without even having used the files yet. Any ideas?

Dismiss AlertView

Hello!

I'm using DLAVAlertView in my project, but I want to dismiss It programmatically.
How can I dismiss this alert?

Thanks ๐Ÿ˜‰

Podspec

Hi there,

Thanks a lot for opensourcing DLAlertview. I made a podspec file for it that I would like to share, the only problem is that it's recommended to use version tags in the spec file. Could you please tag the current version?

Thanks!

Pod update

Hello, first of all, great work!
Will you add the 1.1 version to the pod?
Can't make big customisation with 1.0 version...
thx

Title Label Not Showing

With the latest commit, the title label doesn't seem to be showing in the alert. I've tried a number of combinations, and it still won't appear.

Is not possible display content view in the top when title and message is visible

Please add ability display content in the top. Now it's always in the bottom. I think problem is here:

// Layout title:
if (self.title) {
[self layoutTitleLabelWithTheme:theme inAlertWithSize:alertSize atVerticalOffset:&offset];
}

// Layout message:
if (self.message) {
    [self layoutMessageLabelWithTheme:theme inAlertWithSize:alertSize atVerticalOffset:&offset];
}

self.messageLabel.hidden = self.message == nil;

// Layout content view:
if (self.contentView) { 

Status bar color during alert

Hi,

First of all, I'm not 100% sure this is a bug in DLAlertView. Since I'm using it with JASidePanels library, it may be incompatibility between JASidePanels and DLAlertView.

My app shows white (aKa light content) status bar. But when alert is shown, status bar switches to black text (default). It looks like DLAVAlertViewController doesn't return preferredStatusBarStyle at all. I solved this issue in my app by adding a category onto DLAVAlertViewController:

@implementation DLAVAlertViewController (AlertStatusBar)
- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}
@end

I wonder if it would make sense to make this themable via DLAVAlertViewTheme.

Expose UITextFieldDelegate methods

Would it be possible to expose the UITextFields so that we can respond to the UITextFieldDelegate methods? I notice that internally you are responding to those calls, so I'm not sure if this would be possible.

What I'm trying to do is limit/manipulate the text that is being inputted in the text fields.

Thanks.

iOS5 support

I know, this one is kinda old, but I found this alert-view replacement being by far the most accomplished and it's amazing to see that by changing only a couple of lines you can make it work perfectly on iOS5 (tested on 3GS 5.1.1).

The method body affected is +optimalSizeForLabel:inMaxSize: where the if condition should be using the macro #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 ( or 61000) instead of a test on the Foundation version. This prevents the use of NSFontAttributeName that iOS5 doesn't know and will crash trying to load it.

I don't think that's too much of an issue to modify this, and would be very pleased to see it in future commits !

Have a great day

Textfield enhancements

On show the first textfield is set as first responder and the keyboard appears. In cases where the alert has multiple buttons it may hide the last one: adding a setting to disable the behaviour and let the user bring the keyboard up would be very nice.

When the user clicks the return key of the keyboard the first other button is clicked. Please add the ability to change the index of the button that is clicked or to disable the behaviour. Keep the first other button index or the behaviour enabled as default.

Last one: changing the button the delegate can disable on bad input, this is not always the first other button.

Thanks :)

Supporting iOS 6

Hi. I really like DLAlertView and I want to use it within my app.
But the fact is that its deployment target is 7.0+ so that I cannot integrate it with my app.
I have checked that it works on 6.0 without any problems.
So could you make your library's deployment target to 6.0+ and modify podspec accordingly?
Thanks!

`firstOtherButtonIndex` is wrong if the cancel title is nil

If I set the cancel title to nil:

                DLAVAlertView *alertView = [[DLAVAlertView alloc] initWithTitle:@"title"
                                                                        message:@"message"
                                                                       delegate:nil
                                                              cancelButtonTitle:nil
                                                              otherButtonTitles:@"button1", @"button2", nil];

the firstOtherButtonIndex always is 1:

- (NSInteger)firstOtherButtonIndex  {
    if (self.buttons.count == 1) {
        return (self.cancelButtonIndex == -1) ? 0 : -1;
    }

    return 1;
}

But It should be 0, because the cancel button is not require and the firstOtherButtonIndex should be 0!

Showing alert from previous alert completion block doesn't work

Hi,
I am trying to show an AlertView B right after another one (A) has been closed, from A's completion block. This shows B for a very short time before it disappears. I guess this is a limitation of the implementation but maybe there is a quick fix.

Compiling for iOS7 and under

Hi,

I'm having issues using your lib on old iOS versions, especially since the last bugfix:

DLAVAlertViewController line 218:
[super viewWillTransitionToSize: size withTransitionCoordinator: coordinator];

This method doesn't exist before iOS8 and compiling with it is an issue. Could you add a respondsToSelect: test?

Thank you !

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.