Question

i have an issue related with UIAlertView . i have created an alert with body message and two buttons for OK and Cancel. when i present the alertWindow , the buttons makes its position outside of the alert window and which is not accessable. it will become normal when orientation changes.

i tried by changing the size of the alertWindow but the problem exists.

here is my code

 UIAlertView *errorAlert=[[UIAlertView alloc]initWithTitle:errorAlertTitle message:errorAlertMessage  delegate:self cancelButtonTitle:errorAlertClose otherButtonTitles:@"Reload", nil];
     errorAlert.tag=2;
     errorAlert.frame = CGRectMake(0,0,500,600);

     [errorAlert show];
     [errorAlert release];

enter image description here

any solution?

Was it helpful?

Solution

When you write "alert window", you mean the visible portion of the UIAlertView that has text and buttons, right? Do you think that you are setting the frame of the "alert window" in your code? Are you actually setting the frame of a transparent blocking view that prevents the user from interacting with the rest of the UI and contains the "alert window"? The view hierarchy of UIAlertView is private, so we can't know for sure how it is structured, but you may be manipulating the wrong thing. Note that the documentation also warns against interfering with the UIAlertView view hierarchy, so you may not want to set any view properties like frame for your UIAlertView.

If you really want to modify the "alert window", you could:

  1. Analyze the subviews of the alert view by writing code to walk through them and log useful information (frame, type, etc.). This might tell you which subview you actually want to manipulate.

and then

  1. Use the callbacks in UIAlertViewDelegate to manipulate the alert window after the UIAlertView been constructed and is about to become visible.

But maybe you want to look into UIActionSheet or UIPopoverController if the automatic styling of UIAlertView is not working for you?

OTHER TIPS

To your requirement i just you use actionsheet but for your problem do this:

add this code:

 errorAlert.frame = CGRectMake(0,0,500,600);

after

[errorAlert show];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top