我在 uialertview 中显示一个表格视图,周围出现一条奇怪的白线。我曾尝试更改内容模式,然后调用 [alertView setNeedsDisplay],但它似乎不起作用。
有人可以帮忙吗?谢谢。
// increase the alertview size, if we are going to show the scope
#define ALERT_VIEW_WIDTH 750
#define ALERT_PADDING 20
- (void)willPresentAlertView:(UIAlertView *)alertView {
{
id thing;
if ( [[[alertView class] description] isEqualToString:@"UIAlertTableView"]){ //change the alert view size
int center=alertView.center.x-ALERT_VIEW_WIDTH/2;
for (thing in alertView.subviews)
{
NSLog(@"%@", [[thing class] description]);
if([[[thing class] description] isEqualToString:@"UITableView"])
{
UIView* v=(UIView*)thing;
v.frame=CGRectMake(v.frame.origin.x+ALERT_PADDING, v.frame.origin.y, ALERT_VIEW_WIDTH-ALERT_PADDING*3, 250);
}
if([[[thing class] description] isEqualToString:@"UIAlertButton"])
{
UIView* v=(UIView*)thing;
v.frame=CGRectMake(v.frame.origin.x+ALERT_PADDING, v.frame.origin.y, ALERT_VIEW_WIDTH-ALERT_PADDING*3, v.frame.size.height-10);
}
if([[[thing class] description] isEqualToString:@"UILabel"])
{
UIView* v=(UIView*)thing;
v.frame=CGRectMake(v.frame.origin.x+ALERT_PADDING, v.frame.origin.y, ALERT_VIEW_WIDTH-ALERT_PADDING*3, v.frame.size.height);
}
}
alertView.contentMode = UIViewContentModeRedraw;
alertView.frame=CGRectMake(center, alertView.frame.origin.y, ALERT_VIEW_WIDTH, 360);
[alertView setNeedsDisplay];
}
}
}