Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change width of UIAlertView in iPad

Is there any way to change the frame of the UIAlertView in iPhone or iPad. I tried changing the frame in the following delegate method- (void)willPresentAlertView:(UIAlertView *)alertView;

but even then the width of the Alertview remained unchanged. And I think a small Alertview in iPad will not make sense. And I guess there must be a way to achieve it, at least in iPad.

Thanks, krishnan.

like image 368
RK- Avatar asked May 04 '10 08:05

RK-


1 Answers

Hmm, this code works fine (except, when you are trying to decrease size - cause in this case you can get some bad rendering):

- (void)willPresentAlertView:(UIAlertView *)alertView {
    alertView.frame = CGRectMake(x, y, width, height);
}

Maybe, you forgot to set UIAlertView's delegate with something like someAlertView.delegate = self;

 

UPDATE ↓

codepart:

- (IBAction)go:(id)sender {
    UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:nil
        otherButtonTitles:nil] autorelease];
    alert.delegate = self;
    [alert show];
}

- (void)willPresentAlertView:(UIAlertView *)alertView {
    alertView.frame = CGRectMake(5.f, 1.f, 100.f, 200.f);
}

Result (on my iPod): http://dl.dropbox.com/u/6455784/alert_view_frame.png

like image 57
kpower Avatar answered Oct 01 '22 03:10

kpower