Border access issue on multiple UIAlertViews

I use UIAlertViews to display specific messages in the application, and sometimes my application shows several warnings. The problem occurs when I try to access the boundaries of the alerts.

Here is some code to illustrate the problem. This is added to the new View-based application:

- (void)viewDidLoad {
    [super viewDidLoad];

    [self makeAlert:@"Zero alert" withMessage:@"This is the zero alert"];

    UIAlertView *firstAlert = [[UIAlertView alloc] initWithTitle:@"First Alert" message:@"Here is the first alert" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [firstAlert show];
    NSLog(@"first alert bounds, origin: %f, %f  size: %f, %f",firstAlert.bounds.origin.x,firstAlert.bounds.origin.y,firstAlert.bounds.size.width,firstAlert.bounds.size.height);
    [firstAlert release];

    UIAlertView *secondAlert = [[UIAlertView alloc] initWithTitle:@"Second Alert" message:@"Here is the second alert" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [secondAlert show];
    NSLog(@"second alert bounds, origin: %f, %f  size: %f, %f",firstAlert.bounds.origin.x,firstAlert.bounds.origin.y,firstAlert.bounds.size.width,firstAlert.bounds.size.height);
    [secondAlert release];

    [self makeAlert:@"Third Alert" withMessage:@"Here is the third alert."];
    [self makeAlert:@"Fourth Alert" withMessage:@"Here is the fourth alert."];
}

- (void)makeAlert:(NSString *)makeTitle withMessage:(NSString *)makeMessage {
    UIAlertView *newAlert = [[UIAlertView alloc] initWithTitle:makeTitle message:makeMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [newAlert show];
    NSLog(@"%@ alert bounds, origin: %f, %f  size: %f, %f",makeTitle,newAlert.bounds.origin.x,newAlert.bounds.origin.y,newAlert.bounds.size.width,newAlert.bounds.size.height);
    [newAlert release];
}  

Add the description of makeAlert to the .h file and run this application and you will see the problem in the log. Zero Alert will show the origin 0,0 and the corresponding width and height (284, 141 on 3 / GS). All other warnings show 0.0 for width, height.

Zero ( [self makeAlert...]), firstAlert secondAlert , 0,0.

, 4 5 . . ( ) .

, , , , , , ( , ), , .

, 0,0 ?

+3
1

, - UIAlertView .

. UIAlertView, 0.

UIAlertViewDelegate

- (void)willPresentAlertView:(UIAlertView *)alertView

, UIAlertView. github , TSAlertView

+1

Source: https://habr.com/ru/post/1766513/


All Articles