gpt4 book ai didi

iphone - Table View的带有图片的标题在iPhone 5中不起作用

转载 作者:行者123 更新时间:2023-12-01 16:51:37 25 4
gpt4 key购买 nike

我在我的应用程序的TableView的页眉上设置了图像。

在Iphone 3G中可以正常工作,但是相同的代码在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;
}
}

任何人都可以!在这方面帮助我吗?

最佳答案

为您的headerView和img设置Autoresizingmask希望它会起作用

Autoresizing masks programmatically vs Interface Builder / xib / nib

关于iphone - Table View的带有图片的标题在iPhone 5中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15250326/

25 4 0