manujmv
manujmv

Reputation: 6445

Block not being called and not animating in IOS 7

I am using ShakingAlertView in my app.

https://github.com/lukestringer90/ShakingAlertView

It works perfectly in IOS 6. But after i updating to IOS 7 it didnt animate and the block function for incorrect handing not being called. Given below is the code for the initialization of shaking alert view.

currentPass = [[ShakingAlertView alloc]initWithAlertTitle:@"Enter Current Password" checkForPassword:self.pass
                                                        usingHashingTechnique:HashTechniqueMD5
                                                        onCorrectPassword:^{
                                                            isCurrentPassConfirmed = YES;
                                                            [self._accountSource willScrollToTop];
                                                            self.password.text = @"";
                                                            [self.password becomeFirstResponder];

                                                        } onDismissalWithoutPassword:^{
                                                            //NSLog(@"hi");
                                                            [self showFailedPasswordAlert];

                                                        }];
    currentPass.alertViewStyle = UIAlertViewStyleSecureTextInput;
    [currentPass show];

Below is the method to animate for shake effect.This is invoked correctly but there is no effect.

- (void)animateIncorrectPassword {
    // Clear the password field
    _passwordField.text = nil;

    // Animate the alert to show that the entered string was wrong
    // "Shakes" similar to OS X login screen
    CGAffineTransform moveRight = CGAffineTransformTranslate(CGAffineTransformIdentity, 20, 0);
    CGAffineTransform moveLeft = CGAffineTransformTranslate(CGAffineTransformIdentity, -20, 0);
    CGAffineTransform resetTransform = CGAffineTransformTranslate(CGAffineTransformIdentity, 0, 0);

    [UIView animateWithDuration:0.1 animations:^{
        // Translate left
        self.transform = moveLeft;

    } completion:^(BOOL finished) {

        [UIView animateWithDuration:0.1 animations:^{

            // Translate right
            self.transform = moveRight;

        } completion:^(BOOL finished) {

            [UIView animateWithDuration:0.1 animations:^{

                // Translate left
                self.transform = moveLeft;

            } completion:^(BOOL finished) {

                [UIView animateWithDuration:0.1 animations:^{

                    // Translate to origin
                    self.transform = resetTransform;
                }];
            }];

        }];
    }];

}

Please help me.

Upvotes: 0

Views: 440

Answers (2)

wesley
wesley

Reputation: 859

iOS7 does not allow you to customize the UIAlertview.

  1. Better create the custom view subclass of UIView which is draw the view programmatically using - (void)drawRect:(CGRect)rect method.

  2. And create one more container class(inherited from NSObject) which is used to create and bind your title/password and OK buttons with your custom delegate property into your customized alert view.So that we can implement our custom delegate method as like clickedButtonAtIndex method.

  3. Upto my knowledge there is no changes in block/animation in iOS7.

Or refer this link https://github.com/wimagguc/ios-custom-alertview

Upvotes: 2

Guy Kogus
Guy Kogus

Reputation: 7351

The layout of UIAlertView changed drastically is iOS 7, making it almost impossible to customise and alter. You're going to have to come up with a new solution.

Upvotes: 1

Related Questions