改变iPad中UIAlertView的宽度 [英] change width of UIAlertView in iPad
问题描述
有没有办法在iPhone或iPad中更改UIAlertView的框架。我尝试在以下委托方法中更改框架 - (void)willPresentAlertView:(UIAlertView *)alertView;
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;
但即便如此,Alertview的宽度仍保持不变。我认为iPad中的一个小型Alertview没有意义。我想必须有办法实现它,至少在iPad中。
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.
谢谢,
krishnan。
Thanks, krishnan.
推荐答案
嗯,这段代码工作正常(除非你试图减小大小 - 在这种情况下你可能会得到一些糟糕的渲染):
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);
}
也许,你忘了设置 UIAlertView
的委托与 someAlertView.delegate = self;
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);
}
结果(在我的iPod上): http://dl.dropbox.com/u/6455784/alert_view_frame.png
Result (on my iPod): http://dl.dropbox.com/u/6455784/alert_view_frame.png
这篇关于改变iPad中UIAlertView的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!