garaster 2013-07-31 03:03 采纳率: 0%
浏览 2354
已采纳

标题和表单元之间的空格

我想要让标题和UITableView之间的空隙再大一点。

在网上找到的办法:

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 20.0;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
   //Adding UIView and it's Background Image...
    UIView *tempView=[[UIView alloc]initWithFrame:CGRectMake(0,0,300,20)];
    UIImageView *BgImg=[[UIImageView alloc]initWithFrame:CGRectMake(0,0,300,20)];
    BgImg.image= [UIImage imageNamed:@"venueTitleBg.png"];
    [tempView addSubview:BgImg];

    //Adding UIImageView...
    UIImageView *flag=[[UIImageView alloc]initWithFrame:CGRectMake(10,3,20,12)];
    flag.image= [UIImage imageNamed:@"flag_small_united-kingdom.png"];
    [tempView addSubview:flag];

    //Adding UILabel...
    UILabel *tempLabel=[[UILabel alloc]initWithFrame:CGRectMake(40,1,300,15)];
    tempLabel.backgroundColor=[UIColor colorWithRed:15.0/255.0 green:15.0/255.0 blue:30.0/255.0 alpha:1.0];
    tempLabel.textColor=[UIColor whiteColor];
    tempLabel.font=[UIFont systemFontOfSize:11];
    tempLabel.text=@"United Kingdom";
    [tempView addSubview: tempLabel];

    return tempView;
}

在模拟器中还行,但是在设备上就没效果。

CSDN移动问答

这是在模拟器上的效果。

  • 写回答

1条回答 默认 最新

  • lanhailvcao 2013-07-31 06:03
    关注
    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        return 50.0;
    }
    

    试试看行不行

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?