Alert position is not a center

I have a UIAlertView in a UIView. If an error occurs while logging in, a warning appears.

He once worked on a central position after this image.

enter image description here

My code

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login Failed" message:exceptionString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; 

but once he worked in the left position after this image.

enter image description here

I want only in a central position.

How to fix it. Thanks.

+6
source share
3 answers

How do you show the type of warning? Are you setting a frame with this initWithFrame style?

It should be something like the following.

 NSString *exceptionString = "something"; // where ever you get you failed message. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login Failed" message:exceptionString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; 
+1
source

this can happen if you use transform

 alert.transform = CGAffineTransformMakeTranslation( x, y); 
0
source

@NatthawatSudsang I've seen this before, this happens when you call UIAlertView several times.

 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login Failed" message:exceptionString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; //then some code //more code [alert show]; 
0
source

All Articles