0

I'm trying to create a CustomAlertview using CustomIOS7AlertView, with text and image. Because I read that with simple AlertView is not possible to set a maximun height when we add an image...

My problem is this: I created the CustomAlertView with the image, but I can not in any way, that for the IPAD (in landscape) it is shown in landscape mode. It is always displayed as vertical.

I've tried rotating the customAlertview, but I have not succeeded ...

Could anyone help me?

This is my code:

UIView * vista =  [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
UIImageView *imgView;

if (([[UIDevice currentDevice].model rangeOfString:@"iPad"].location!=NSNotFound)) {

    imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 400, 400)];

} else {

    imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];   
}

[imgView setImage:img];
[vista addSubview:imgView];            

CustomIOS7AlertView *alertView = [[CustomIOS7AlertView alloc] init];
[alertView setContainerView:vista];

[alertView show];

screenshot of the problem

Thank you!!!

Dipu Raj
  • 1,784
  • 4
  • 29
  • 37

2 Answers2

2

Put observers for orientation change in CustomIOS7AlertView and then make the view correctly oriented every time orientation is changed.

Refer to : Detecting iOS UIDevice orientation to understand more on orientation change notifications.

Community
  • 1
  • 1
prabodhprakash
  • 3,825
  • 24
  • 48
0

Solved! As the colleague noir_eagle said, the problem was in the show (CustomIOS7AlertView.m) method, in particular had to modify the following line, which affects the rotation:

UIInterfaceOrientation interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
        switch (interfaceOrientation) {
            case UIInterfaceOrientationLandscapeLeft:
                **self.transform = CGAffineTransformMakeRotation(M_PI * 360 / 180.0);**

Thank you ver much! ;)