我在我的应用程序中为 TableView 的标题设置图像。
它在 Iphone 3Gs 中运行良好。但相同的代码在 Iphone 5 中不起作用。它仅显示具有非常小尺寸图像的框架。
当我增加帧宽度时,图像不会增加。
这是我的代码:
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
CGSize result = [[UIScreen mainScreen] bounds].size;
NSLog(@"height%f",result.height);
if(result.height > 500){
NSLog(@"iPhone 5");
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320,30)];
UIImageView *img = [[UIImageView alloc]initWithFrame:headerView.frame];
if(tableView == tableview1)
{
img.image = [UIImage imageNamed:@"My Contacts Overlay.fw.png"];
}
else if(tableView == tableview2)
{
img.image = [UIImage imageNamed:@"My Contacts Overlay2.fw.png"];
}
[headerView addSubview:img];
return headerView;
}
}
任何人都可以请!帮帮我?