GithubHelp home page GithubHelp logo

alexanderjarvis / pxalertview Goto Github PK

View Code? Open in Web Editor NEW
592.0 19.0 95.0 1.18 MB

A drop-in replacement for UIAlertView that is more customisable and skinnable

License: MIT License

Objective-C 98.93% Ruby 1.07%

pxalertview's Introduction

PXAlertView

PXAlertView is a UIAlertView replacement similar to the style in iOS 7 but with a block based API and the ability to customise the styling and add custom views.

Preview

Demo Animation

Features

  • Simple block syntax instead of delegates
  • Animations that match UIAlertView in iOS 7
  • Fully customisable
  • Add your own UIView beneath the title

Installation

Add the following to your CocoaPods Podfile

pod 'PXAlertView', '~> 0.1.0'

or clone as a git submodule,

or just copy PXAlertView.h and .m into your project.

Usage

See PXAlertView.h for the complete API.

An Example

[PXAlertView showAlertWithTitle:@"The Matrix"
                        message:@"Pick the Red pill, or the blue pill"
                    cancelTitle:@"Blue"
                     otherTitle:@"Red"
                     completion:^(BOOL cancelled, NSInteger buttonIndex) {
                         if (cancelled) {
                             NSLog(@"Cancel (Blue) button pressed");
                         } else {
                             NSLog(@"Other (Red) button pressed");
                         }
                     }];

TODO

  • Add style that matches iOS 7 exactly
  • Ability to dynamically specify the styling of AlertView: default/dark

License

PXAlertView is available under the MIT license. See the LICENSE file for more info.

pxalertview's People

Contributors

adobkin avatar alexious-sh avatar bryanwayb avatar debris avatar forgot avatar maximbilan avatar muer2000 avatar mzygar avatar regexident avatar shortcutman 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

pxalertview's Issues

isn't suitable with iOS8 +

The UIAlertView in iOS8 should be replaced with UIAlertViewController,or it will lead to bugs occur. At the same time, when clicking buttons on the UIAlertView, views beneath the UIAlertView can be touched.

Alertview repeats its show animation

If i use an alertview with a text based content view and tap on it, it brings the keyboard up. If the keyboard is still up when i call another alertview in the completion block, the entry animation is repeated

Alert presented only at next occasion

Hi,

I'm using 2 PXAlerts in a modal IOS view that presents a tableview with two choices. One alert fires when the user selects one of the tabs. That works fine. The second alert is supposed to fire at the end of the method invoked by the users choice. Often times that works just fine. Other times however, the alert doesn't show and the modal screen gets dismissed with out the user getting a chance to confirm the Alert by clicking ok. Oddly enough, the underlying screen seems to be in a state in which the alert usually would come up (dimmed brightness, grated out areas).

If I go back to that modal view and do the same drill again, the first alert comes up without problems at the right time but the second alert would get presented two times in a row. It feels as if the alert from the first round just jammed and gets then kick out together with the new alert.

Any ideas? Thanks in advance!
Dirk

Functionality for a next version of alert view

Hi, great work on this very useful class. Is it possible to add an option to disable or remove buttons in the alert view, to selectively dismiss in a non-canceling fashion until certain conditions have been met, that allow to proceed with its dismissal.

In case of finding it helpful, I can help with the coding of the said implementations.

Displaced 2nd alert view and dead interface

I've reported already this as comments on a closed issue (#13):

Showing an alert view inside the completion block from an other alert view
(in connection to UISplitViewController)
leads to following issue on iPad (testet under iOS 7.x) in landscape orientation:

After dismissing second alert view the interface is "dead". No more interaction with the app
is possible…
The second alert view is then displaced (center position of whole screen is shifted in x-direction).

This issue you can reproduce by taking the demo project,
adding a new button in iPad storyboard (is yet incomplete) connected to showAlertInsideAlertCompletion:
and run it on iPad in landscape orientation. See screenshots!

1st alert view:
1st alert view

2nd alert view inside completion block of 1st alert view:
2nd alert view inside completion block of 1st alert view

The problems went away when creating a new alert window (UIWindow with UIWindowLevelAlert) for every alert view resp. do not reusing the existing alert window.
I guess the basic problem is located in way of reusing the single alert window.

Requested Functionality v2.0

HI. Thanks for the great work. Is it possible to add a method to change the origin.x and origin.y of the alert? In other words something like:

customAlert.transform = CGAffineTransformTranslate( customAlert.transform, -160.0, 0.0 );

or something similar???

Alert view stays hidden by keyboard

Hello.
I've added a textview as a content view but when the keyboard comes up it hides half of alert view, i.e. alert view is not moving up. :(
Is it possible to make it to move up?
Thank you.

Dismiss queued alerts if view is popped

This may already exist, and I just can't figure it out, but is there a way to dismiss all alerts created by a particular view when that view is popped? I'm running in to an instance where the alert is queued by View B, the user pops the view by pressing the back button on the navigation bar to return to View A, but the alert still fires and displays on View A. (As a side note to that, whenever this happens the alert view can be dismissed, but doesn't remove the window its using to display itself, and blocks the UI.)

I see that there is an array containing all the alert views to be displayed, but it's internal to the implementation. If what I'm looking for is not currently possible, what do you think of adding a sender property to the alert view, and allowing all queued alert views from that sender to be canceled when the view is popped?

iOS 13 - Manually adding the rootViewController's view to the view hierarchy

I'm still using this alert view since I needed night-vision alerts on a rather niche app, with some minor fixes over the years, but with iOS 13 it seems the way the view is loaded itself won't work for long as I get:

Manually adding the rootViewController's view to the view hierarchy is no longer supported. Please allow UIWindow to add the rootViewController's view to the view hierarchy itself.

at:
[self.alertWindow makeKeyAndVisible];

I haven't really tried to solve this, as it still seems to work with that warning, but in case anyone has looked at it...

PS. I looked at it and just had to remove the line self.alertWindow.rootViewController = self it seems - oh, but then landscape doesn't work, woops, I'll look at it again!

can you post an example of using contentView to show?

      UIView *uv=[[UIView alloc]initWithFrame:CGRectMake(100, 100, 500, 500)];
       [uv setBackgroundColor:[UIColor blueColor]];
        [PXAlertView showAlertWithTitle:@"系统提示"
                                message:@"登录失败"
                            cancelTitle:@"确定"
                            contentView:uv
                             completion:^(BOOL cancelled, NSInteger buttonIndex) {}];


where is wrong?

Changing Font Size Should Redraw Alert

If you change the font for a long multiple line message or title, the label heights should be recalculated.

For example, decreasing the font size will cause large spaces at the top and bottom of the message.

Requested Functionality

  1. Can you add a property to disable/enable tapping to dismiss feature?
  2. Possible to make public the dismiss method? If I want to call it manually, for example.
  3. Create a alert with no buttons, if lets say I want to just show a message to a user, and dismiss it after 3 seconds.

Possibility to change Line Color

It can be cool to offer the possibility change the line color, because on white background, there is no line visible.

ex :

- (CALayer *)lineLayer
 {
     CALayer *lineLayer = [CALayer layer];
    lineLayer.backgroundColor = [self.lineColor CGColor];
    return lineLayer;
 }

[alert setCancelButtonBackgroundColor: not been called

The following is never called (even in your example) in the - (IBAction)showSimpleCustomizedAlertView:(id)sender {
....

[alert setCancelButtonBackgroundColor:[UIColor redColor]];

}

any ideas why? Also it would be great if we had a alert setCancelButtonTitleColor as well...

ld: warning: instance method 'setBackgroundColorForButton:'

I get a warning when attempting to compile my project with PXAlertView (but only if I include the +Customization files).

ld: warning: instance method 'setBackgroundColorForButton:'

I am using Xcode 5.0.2.

This error is present in the Demo.

Message font changes require sizeToFit

[self.messageLabel sizeToFit]; should be used when setting the message font; if you use a font other than the system font, you'll end up with truncated text.

Except that makes it goofy too. Something to do with AutoLayout, will re-open when I have a solution.

orientation

I change screen orientation, during orientation the AlertView background color become black

Small bug on iOS 5.x

Regardless of the orientation of device shows an alert only in portrait orientation

Dismiss Programatically

Hi guys, whats up ? I want dismiss my PXAlertView programatically without click in button, is there an event/function for this ? I really need this. Thanks

PS: dismiss view controller function not worked.

Buttons / UITextField

I was looking for a replacement for the uialertview with three buttons, ok, forgot and cancel, be nice to see a screenshot with more buttons and a uitextfield, maybe example code showing how to access the text value too.

cocoapods version 0.0.4

Hi,

it seems the cocoapods spec refers a non existing tag:

Installing PXAlertView (0.0.4)
[!] Pod::Executable fetch origin tags/0.0.4 2>&1

fatal: Couldn't find remote ref tags/0.0.4

fatal: The remote end hung up unexpectedly

Or the readme specifies a wrong version.

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.