Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
表视图';带有图像的s标题在iPhone 5中不起作用_Iphone_Ios_Xcode_Uitableview_Tableheader - Fatal编程技术网

表视图';带有图像的s标题在iPhone 5中不起作用

表视图';带有图像的s标题在iPhone 5中不起作用,iphone,ios,xcode,uitableview,tableheader,Iphone,Ios,Xcode,Uitableview,Tableheader,我正在应用程序中为TableView设置标题上的图像 它在iPhone3GS中运行良好,但同样的代码在iPhone5中不起作用。 它只显示只有非常小尺寸图像的帧 当我增加帧宽度时,图像没有增加 这是我的密码: -(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdio

我正在应用程序中为TableView设置标题上的图像

它在iPhone3GS中运行良好,但同样的代码在iPhone5中不起作用。 它只显示只有非常小尺寸图像的帧

当我增加帧宽度时,图像没有增加

这是我的密码:

-(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;
        }
}

谁都可以!帮我做这件事?

为你的头像视图和img设置自动重新设置任务…希望它能起作用


您是否设置了
头部高度部分
返回视图高度?@ipatel您编辑了我的代码吗?@user2134883--是的……为什么?我不知道您在哪里做了更改?我猜您为retina3.5全屏(适用于iphone3g)和retina4全屏(iphone5)创建了此布局,两者的大小不同,选择任何布局(xib)文件时,可以在属性检查器中检查此项。