Giter Site home page Giter Site logo

sdcalertview's People

Contributors

bcherry avatar castles avatar cruisediary avatar csr avatar esilverberg avatar fnxpt avatar franklsf95 avatar ftp27 avatar futuretap avatar gereons avatar junpluse avatar justin999 avatar kurry avatar mumez avatar myster-t avatar nirajignited avatar nschum avatar nzhuk avatar petrpavlik avatar redetection avatar sberrevoets avatar scott90 avatar scottcwilliams511 avatar tdesert avatar tizaks avatar twiedow avatar woxtu avatar yccheok avatar zgl6yxnt avatar zidaneno5 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

sdcalertview's Issues

Crash when changing view hierarchy after showing

When an alert is modified in a way that it changes the view hierarchy (for example, changing the alertViewStyle to include a text field where previously it didn't) currently causes a crash because the alert tries to add constraints to views that aren't part of the view hierarchy.

The view hierarchy is built exactly once, when it is sent show (or showWithDismissHandler:), so any view hierarchy changes after that will result in a crash.

An obvious workaround until I fix this is to make sure the view hierarchy doesn't change after calling show.

How to change the width of the SDCAlertView ?

Hello,

I wonder if it's possible to change the width of the SDCAlertView. Here my piece of code:

    _alertView = [[SDCAlertView alloc] initWithTitle:@""
                                             message:@""
                                            delegate:self
                                   cancelButtonTitle:@"Ok"
                                   otherButtonTitles:nil];

    UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 600, 600)];

    NSString *path = [[NSBundle mainBundle] bundlePath];
    NSURL *baseURL = [NSURL fileURLWithPath:path];

    [webview loadHTMLString:htmlString baseURL:baseURL];
    [webview setBackgroundColor:[UIColor clearColor]];
    [webview setOpaque:NO];
    [webview setDelegate:self];
    webview.scrollView.scrollEnabled = TRUE;
    webview.scalesPageToFit = TRUE;

    [webview setTranslatesAutoresizingMaskIntoConstraints:NO];
    [_alertView.contentView addSubview:webview];

    [webview sdc_pinWidthToWidthOfView:_alertView.contentView];
    [webview sdc_pinHeightToHeightOfView:_alertView.contentView];
    [webview sdc_horizontallyCenterInSuperview];
    [webview sdc_verticallyCenterInSuperview];
    [webview sdc_pinHeight:600];
    [webview sdc_pinWidth:600];

    [_alertView.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[webview]|"
                                                                              options:0
                                                                              metrics:nil
                                                                                views:NSDictionaryOfVariableBindings(webview)]];

    [_alertView show];

    return YES;

The hight is ok: 600 pixels, but the width is all the time 270 pixels.

Could you please explain why I can't change the width ?
Thank you so much, and thank you for this beautiful library! ;)

Regards,
Christophe.

How to make 2 vertical buttons?

SDCAlertView *alert = [[SDCAlertView alloc] initWithTitle:@"Title"
                                                  message:@"This is a message"
                                                 delegate:self
                                        cancelButtonTitle:@"Cancel"
                                        otherButtonTitles:@"OK", nil];
[alert show];

Result:
screen

The desired result:
screen2

Auto-rotation happens even when presenting controller returns 'shouldAutoRotate' as 'NO'

Using SDCAlertView as follows, the controller that presents the alert view returns shouldAutoRotate as 'NO', however SDCAlertView sill rotates.

Is there an easy way to turn this off?

Its not possible to use SDCAlertController, as the view is being presented as follows:

  • Camera Scanning view
  • A 'frosty' overlay on the camera view. Works like [self presentViewController] except it has a custom animation on presentation, and uses UIToolbar to give a real-time iOS blur on the camera feed.

(seems SDCAlertController doesn't like the above), but SDCAlertView is happy enough, except for the minor issue of unwanted auto-rotation.

Presenting Controller

The window has been given a root view controller, in this case a dedicated one, with its view having containers matching the diagram below.

containment

  • Encapsulates app-wide UI concerns, and provides an interface for these.
  • Provides a container for application layout, and the appropriate to define custom animations for the presentation and dismissal of these views.
  • Makes UIViewContainment calls (willMoveToParentController, etc) when presenting dismissing contained views.

The implementation of shouldAutoRotate in the custom root controller is:

- (BOOL)shouldAutorotate
{
    BOOL shouldAutoRotate = NO;
    if (_overlayController) {
        if ([_overlayController isKindOfClass:[UINavigationController class]]) {
            shouldAutoRotate = [((UINavigationController *) 
                _overlayController).topViewController shouldAutorotate];

        }
        else {
            shouldAutoRotate = [_overlayController shouldAutorotate];
        }
    }
    else {
        UIViewController *topController = _navigator.topViewController;
        shouldAutoRotate = [topController shouldAutorotate];
    }
    return shouldAutoRotate;
}

. . . the above autoRotate works as expected everywhere except for the SDCAlertView that is being presented as described. Adding a debug shows that:

  • While the alert view is being presented, the first shouldAutoRotate returns the auto-rotation of _overlayController.topViewController, which is 'NO'. Yet auto-rotation still happens.

3 Button Stacking

Is it possible to show a 3 button alert like UIAlertView?

screen shot 2014-08-27 at 10 26 04 am

SDCAlertView is stacking the buttons.

Confirm iOS 7.1 alert rendering issue

I want to double check that the issue I'm seeing isn't just restricted to the simulator and, if verified, we need to file a Radar because I'm pretty sure it's subtle enough to not have been detected by anyone else. After all, who else stares at their monitor for extended periods watching UIAlertViews animate in and out, etc? Exactly.

Steps:

  1. Fire up the 7.1b5 (perhaps earlier, not sure) iPhone 4" Simulator (32-bit arch)
  2. Run the SDCAlertView demo project
  3. Select the top item "Show System Alert"
  4. Watch very, very carefully as the alert animates into view
  5. After the alert view comes to rest, you will see its overall background color shift to a darker color.

This is a regression that causes the apparent color of the alert to be several shades darker than it otherwise would've been on iOS 7.0.x. This makes the contrast between the alert and its dimming/backdrop view somewhat lower, which indicates that this is likely a regression rather than expected behavior. Also the fact that the transition from the "lighter" state to the "darker" state is extremely abrupt.

If this is confirmed, a Radar should be filed and immediately duped.

SDCAlertView capture of _userWindow race condition

I had two cases where SDCAlertView was not dismissing properly. Specifically, it wasn't reverting back to the correct key window. One case was when an SDCAlertView was presented as a result of a button selection in an UIActionSheet. The other was a SDCAlertView presented in viewDidAppear: in a modal view controller (which was contained in a UINavigationController). I tracked it down to -[SDCAlertViewCoordinator init] when it captures a reference to _userWindow. In one of my cases, the window it was capturing was an instance of _UIAlertOverlayWindow. I replaced the said line with:

_userWindow = [UIApplication sharedApplication].keyWindow;
if (![_userWindow isMemberOfClass:[UIWindow class]])
    _userWindow = [UIApplication sharedApplication].windows[0];

AlertView position not correct

Step 1: Set the alertViewStyle property to SDCAlertViewStylePlainTextInput or SDCAlertViewStyleLoginAndPasswordInput.
Step 2: Turn the iPad simulator to landscape mode.
Step 3: Tap to show the alert view.
Step 4: Tap the textfield in the alert view.

Now you can see the alert view position is not correct.

PS: I use the iOS7 simulator.

iOS7 - contentView subview ignores center autolayout

On iOS7 I'm trying to add a view as a centered subview of the content view.

The auto layout is being ignored for whatever reason and the view is being added to x=0 on the contentview.

My code looks like this:

    _emptyFolderProgressDialog = [SDCAlertController alertControllerWithTitle:NSLocalizedString(@"Emptying Deleted Items", nil)
                                                                      message:nil
                                                               preferredStyle:[UIDevice isIos7] ? SDCAlertControllerStyleLegacyAlert : SDCAlertControllerStyleAlert];
    IndeterminateProgressView *progressView = [[IndeterminateProgressView alloc] initWithStyle:progressViewStylePurple];
    [progressView setTranslatesAutoresizingMaskIntoConstraints:NO];
    [progressView startAnimating];
    [_emptyFolderProgressDialog.contentView addSubview:progressView];
    [progressView sdc_horizontallyCenterInSuperview];
    [progressView sdc_verticallyCenterInSuperviewWithOffset:kProgressDialogVerticalOffset];

But what I am getting on screen is this shown below.

screen shot 2014-10-24 at 17 40 50

On iOS8 this problem does not exist, and the progress indicator is rendered in the center of the view.

Dismiss alert without animation

When calling -[SDCAlertView dismissWithClickedButtonAtIndex:animated:], the animated argument is ignored and alerts are always dismissed with animation.

Getting some errors logged for layout

Causes no discernible problem other than error being logged.

<<<< (61 seconds after request) 
2014-10-21 11:13:15.873 Infiniti[739:148251] Unable to simultaneously satisfy constraints. 
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)  
( 
    "<NSLayoutConstraint:0x17583480 SDCAlertLabel:0x17677250'The operation couldn\U2019t be...'.firstBaseline == SDCAlertLabel:0x17676bf0'Error'.lastBaseline + 18>", 
    "<NSLayoutConstraint:0x1767f620 SDCAlertLabel:0x17677250'The operation couldn\U2019t be...'.firstBaseline == SDCAlertLabel:0x17676bf0'Error'.lastBaseline + 18>" 
) 

Will attempt to recover by breaking constraint  
<NSLayoutConstraint:0x17583480 SDCAlertLabel:0x17677250'The operation couldn’t be...'.firstBaseline == SDCAlertLabel:0x17676bf0'Error'.lastBaseline + 18> 

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. 
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. 

another race condition when dismissing an alert

This one seems to occur when I try to manually dismiss an alert that has already been programmatically dismissed, but the UI hasn't caught up yet.

The code is below. Wire this up to any button in your UI, and then immediately try to close the first alert before it disappears. This locks up the entire UI.

SDCAlertView* alert1 = [[SDCAlertView alloc] initWithTitle:@"Alert 1"
                                                     message:@"This one will be immediately dismissed, but if I hit the cancel button on it first, it will ruin everything."
                                                    delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
  SDCAlertView* alert2 = [[SDCAlertView alloc] initWithTitle:@"Alert 2" message:@"This one should remain up."
                                                    delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
  [alert1 show];
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [alert1 dismissWithClickedButtonIndex:0 animated:NO];
    [alert2 show];
  });

Note that I can only reproduce this if animated is NO in the programmatic dismissal.

Two issues found: crash on buttonTitleAtIndex & constraint warning

I met two issues with following code:

#import "ViewController.h"
#import "SDCAlertView.h"


@interface ViewController ()

@property(strong, nonatomic) SDCAlertView *alert;

@end


@implementation ViewController

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    _alert = [[SDCAlertView alloc] initWithTitle:@"title"
                                         message:nil
                                        delegate:nil
                               cancelButtonTitle:@"cancel"
                               otherButtonTitles:@"ok", nil];
    [_alert showWithDismissHandler:^(NSInteger buttonIndex)
    {
        // crash if use -1 as button index
        NSLog( @"buttonTitleAtIndex = %@", [_alert buttonTitleAtIndex:buttonIndex] );
    }];

    [self performSelector:@selector( onTest ) withObject:nil afterDelay:1];
}

- (void)onTest
{
    [_alert dismissWithClickedButtonIndex:0 animated:NO];  // crash if use -1 as button index

    // will see constraint warning here in Xcode console, debug mode
    _alert.message = @"message";
    [_alert show];
}

@end

Dismissal of SDCAlertController fails on iOS7

On iOS7 I am unable to dismiss the SDCAlertController with the same code that works on iOS8.

The dismiss code looks as follows:

        [self.emptyFolderProgressDialog dismissWithCompletion:^
        {
          // some code
        }];

What I'm finding is that this dismissWithCompletion looks like this:

  • (void)dismissWithCompletion:(void (^)(void))completion {
    [self.presentingViewController dismissViewControllerAnimated:YES completion:completion];
    }

But the self.presentingViewController is nil - hence nothing is dismissed.

I am showing the SDCAlertController using this code:

    _emptyFolderProgressDialog = [SDCAlertController alertControllerWithTitle:NSLocalizedString(@"Emptying Deleted Items", nil)
                                                                      message:nil
                                                               preferredStyle:[UIDevice isIos7] ? SDCAlertControllerStyleLegacyAlert : SDCAlertControllerStyleAlert];
        [self.emptyFolderProgressDialog presentWithCompletion:nil];

Showing the SDCAlertView works fine (apart from the layout issue I opened) but it's not possible to dismiss on iOS7.

Top separator not shown if title and message = nil

If only a custom view is used and title/message is set to nil, the separator above the buttons (I am using two buttons, cancel and ok) is not shown. If I add a title and/or message, the separator is displayed correctly.

missing files

missing "UIView+SDCAutoLayout.h" and "UIView+SDCAutoLayout.m" in zip

image

iOS8 beta iPad Alert Position with Keyboard

I've got an alert with alertViewStyle set to UIAlertViewStylePlainTextInput. Its working fine for iOS7 but in iOS8 its positioning the alert off the screen (only in landscape mode). This may be fixed in the gold master but I thought I would mention it.

SDCAlertViewWidth not public

It could be beneficial, especially when using the contentView, to have access to the width of an alert through a constant. This constant exists (SDCAlertViewWidth), but only in SDCAlertView_Private.h and not in the normal SDCAlertView.h.

bug in new custom padding code

Now that the code uses self.contentPadding in SDCAlertViewContentView, I found an issue.

When the content view is initialized, the appearance hasn't yet been applied, so when initializing the title and message labels, the following doesn't work:

self.titleLabel.preferredMaxLayoutWidth = SDCAlertViewWidth - self.contentPadding.left - self.contentPadding.right;

self.messageLabel.preferredMaxLayoutWidth = SDCAlertViewWidth - self.contentPadding.left - self.contentPadding.right;

This is because self.contentPadding isn't yet initialized here, so the layout widths don't get set right, and I'm finding that the end result is that sometimes my labels don't get sized properly.

Adding a subview to SDCAlertView doesn't work properly on iOS 8 GM?

I had used an instance of SDCAlertView in my project to add a UITextView inside an alert to do some facebook posts.It doesnt seem to work properly anymore on ios8.

I had used the following code.

SDCAlertView *alert = [[SDCAlertView alloc] initWithTitle:@"Post To Facebook"
                                                      message:@""
                                                     delegate:nil
                                            cancelButtonTitle:@"Cancel"
                                            otherButtonTitles:@"Post", nil];
    UITextView *textView = [[UITextView alloc] init];
    [textView setTranslatesAutoresizingMaskIntoConstraints:NO];
    [textView setEditable:YES];
    textView.autocorrectionType = UITextAutocorrectionTypeNo;
    [alert.contentView addSubview:textView];
    [textView sdc_pinWidthToWidthOfView:alert.contentView offset:-5];
    [textView sdc_pinHeight:120];
    [textView sdc_horizontallyCenterInSuperview];
    [textView sdc_verticallyCenterInSuperviewWithOffset:SDCAutoLayoutStandardSiblingDistance];
    [alert showWithDismissHandler: ^(NSInteger buttonIndex) {
        NSLog(@"Tapped button: %@", @(buttonIndex));
        if (buttonIndex == 1) {
            NSLog(@"POST %@", textView.text);
        }
        else {
            NSLog(@"Cancelled");
        }
    }];

iOS 7
ios simulator screen shot 12 sep 2014 21 09 39
iOS 8 GM
ios simulator screen shot 12 sep 2014 21 08 11

Allow setting of cancel button index

Setting the cancelButtonIndex property doesn't do much right now, except for causing the model and view to be out of sync. UIAlertView allows setting an "other" button to be the cancel button, so SDCAlertView should do the same.

Readjusting windowTintAdjustmentMode after dismissal causes sudden color change

I have several UIImages that render according to tintAdjustmentMode and when the alerts show they gray out nicely, as expected, but on dismissal the whole alert fades and then the tintAdjustmentMode suddenly snaps off

I found that but setting the mode to Automatic before the last alert dismisses fixes this issue, or at least the ugly snap I was seeing before is less noticeable since it happens as the alert fades away

Cheers

SDCAlertView doesn't work in Action Extension context

Hi there, I'm trying to make a safari extension for iOS 8 at the moment, and I found that SDCAlertView doesn't get shown at all when I call [alert show], and it seems that the built-in UIAlertView doesn't get shown either. The only way to get an alert is to use the new UIAlertController, and it still doesn't support subviews...

Will SDCAlertView be updated to support usage in extension context?

Podspec does not include background image

The podspec file is not set up to include the background image(s) (SDCAlertViewBackground.png and its Retina equivalent) in version 0.9. For now, download the image(s) separately and add them manually.

NSInvalidArgumentException when setting alertViewStyle

When I create an SDCAlertView using one of the convenience class methods and then set alertViewStyle to e.g. SDCAlertViewStylePlainTextInput, I get an NSInvalidArgumentException related to layout constraints.

I'm not sure if this is a misunderstanding on my part or a (documentation?) bug.

Automatically determine contentView height based on subviews

Instead of requiring the contentView's height to be set manually, it should be able to deduct the height based on the subviews. Since most of the time the height is determined by [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(view)], giving it an intrinsic content size makes that constraint obsolete.

It could probably use the functionality of SDCIntrinsicallySizedView for this functionality.

Background is missing in iOS 7.1 beta

Neither on simulator nor on real device the background is gone.
I've checked if there is any background and everything should be fine but as you can see…

screenshot 2013 12 30 22 56 02

The toolbar hack as a background is undesired

This issue continues the discussion in #12, which has been fixed but in a way that's not recommended as it has the potential to break or even be rejected by Apple.

Summary

A UIToolbar, which internally uses _UIBackdropView (a private class) to create its background, is added as the top-level subview of an SDCAlertView instance to provide the alert with the same background as UIAlertView. This is obviously not how UIToolbar is supposed to be used, which is why it's a hack.

UIAlertView uses that same _UIBackdropView class, but SDCAlertView can't use that due to it's privateness. _UIBackdropView has a huge number of methods and properties and reverse-engineering this won't be easy.

race condition when displaying multiple AlertViews

I suspect there may be some issues with the queuing code that are worth investigating.

In particular, if I try to dismiss one SDCAlertView (using dismissWithClickedButtonIndex()) and show another in the same block of code (using show()), the first one goes away but the second one never appears (or briefly appears). After doing this, subsequent calls to show() also don't work.

I have found a workaround (call the show before the dismiss), but this leads to some awkward code readability and I think is just masking the underlying issue. Let me know if you'd prefer I file things like this elsewhere, and thanks for a fantastic library!

Listening for Touches

In iOS6, I implemented an alert which contains a UITableView. With iOS7 clearly the default alert doesn't work.
With your implementation I have managed to dynamically switch in SDCAlertView as the superclass if the current version is iOS7 or newer.
For most situations this works, however for tableViews, while they appear correctly on the alert, they don't seem to receive any touches - so if you try to tap on a cell, nothing happens.
I'm still early in debugging this, and it may well be something simple with my implementation. I thought it best though to check with you to see if this is a known issue and/or if there is a work around for it.

enhancement request: allow change of width dimensions

in using SDCAlertView I want to display an image in the contentView which is 500x500 dimensions. You have a const SDCAlertViewWidth defined as 270 so max width is 270. Is it possible to give a method to allow me to override this and set the width to whatever I want in order to display the contentView nicely?

SDCAlertView subclasses can't have an init

We subclass SDCAlertView and our subclass had an init function. That caused an infinite loop.

We called our init
Our init actually called another initWith... function of ours
Our initWith... function called initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles: on SDCAlertView
That called init (which was OUR init not the SDCAlertView init)

... and the infinite loop continues.

Easy fix for us. We just had to remove our init function and do things a different way, but that may surprise other people that attempt to subclass SDCAlertView.

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.