Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landscape support? #5

Open
flyman27 opened this issue May 6, 2014 · 7 comments
Open

Landscape support? #5

flyman27 opened this issue May 6, 2014 · 7 comments

Comments

@flyman27
Copy link

flyman27 commented May 6, 2014

comes in from the top and sideways of course. Any places I can start looking to fix that?

Also I added a dismiss delegate.

@mtonio91
Copy link
Owner

mtonio91 commented May 6, 2014

I'm not a big fan of landscape mode on iphone, even more for pop ups/alerviews that's why i haven't implemented it but i could make it compatible.

@flyman27
Copy link
Author

flyman27 commented May 6, 2014

Thanks! I have an app that presents a lot of stuff in landscape (movies, etc) and it would take your cool api over the top!
Im looking through it now to see where I could add it

@mtonio91
Copy link
Owner

mtonio91 commented May 6, 2014

If you want to figure it out from yourself, you can have a look to the relative coordinates of the alertview which are based on window frame and not and self.view frame.

And then do a pull request :)

@fivecord
Copy link

fivecord commented May 9, 2014

I could use the landscape-support to, specially for iPad-apps...

@fenlandersoftware
Copy link

+1 for iPad / landscape support - anyone have any hack's they can share ?

@iJoshy
Copy link

iJoshy commented Jan 5, 2015

+100 for iPad / landscape support - does anyone have any hack they can share ?

@dupuis2387
Copy link

This worked for me....

in AMSmoothAlertView.m...
add

#define kCircleViewTag 9999

at the top as a const

at the bottom of

  • (void) _initViewWithTitle:(NSString )title andText:(NSString *)text andCancelButton:(BOOL)hasCancelButton forAlertType:(AlertType)type andColor:(UIColor) color
    {
    //----snipped for brevity ----//
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver: self
    selector: @selector(deviceOrientationDidChange:)
    name: UIDeviceOrientationDidChangeNotification
    object: nil];
    }
  • (void)deviceOrientationDidChange:(NSNotification *)notification {
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    self.frame = screenRect;
    alertView.center = self.center;
    CGRect circleViewFrame = [self viewWithTag:kCircleViewTag].frame;
    circleViewFrame.origin.x =screenRect.size.width/2;
    circleViewFrame.origin.y =((screenRect.size.height/2)-alertView.frame.size.height/2);
    [self viewWithTag:kCircleViewTag].frame = circleViewFrame;
    }
    -(void) dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver: self];
    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
    }

the in i add the tag defined at the top to the circle mask view

  • (void) circleSetupForAlertType:(AlertType) type andColor:(UIColor*) color
    {

    UIView * circleMask = [[UIView alloc]initWithFrame:CGRectMake([self screenFrame].size.width/2, (([self screenFrame].size.height/2)-alertView.frame.size.height/2) , 60, 60)];
    circleMask.tag = 9999;

//----snipped for brevity ----//

}

P.S. I utterly ditched the background blur view, so this "hack" or "patch" doesnt pay any attention to the blur view/variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants