相关疑难解决方法(0)

在标题上保留UITableView填充但在IOS7上的分隔符中没有

在iOS7上进行转换时,分隔符左侧有15px填充.我知道我可以在xib文件中的UITableView设置中使用分隔符插入功能删除此填充,但我需要使用填充保持标题文本.怎么做?

默认:

在此输入图像描述

使用自定义分隔符插入0:

在此输入图像描述

我需要像图2那样保留分隔符,但标题为"2013"​​,如图1所示.

iphone uitableview separator ios ios7

24
推荐指数
2
解决办法
2万
查看次数

如何在以编程方式创建的UILabel上添加padding-left?

我知道这是一个菜鸟问题,但是...我在桌面视图上有这些标签,但文字完全被压到了左边.我想添加一些填充.我该怎么办呢?

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section  {

    UIView* customView = [[[UIView alloc] initWithFrame:CGRectMake(10,0,300,60)] autorelease];

    UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];

    headerLabel.backgroundColor = [UIColor colorWithHexString:[[_months objectAtIndex:section] objectForKey:@"color"]];
    headerLabel.font = [UIFont boldSystemFontOfSize:18];
    headerLabel.frame = CGRectMake(0,0,400,30);
    headerLabel.text =  [[_months objectAtIndex:section] objectForKey:@"name"];

    headerLabel.textColor = [UIColor whiteColor];


    [customView addSubview:headerLabel];

    return customView;
}
Run Code Online (Sandbox Code Playgroud)

任何帮助深表感谢!谢谢!

iphone objective-c ios

21
推荐指数
4
解决办法
7万
查看次数

如何填充 UITableView 节标题?

如何向 UITableView 单元格中的节标题添加一些填充?

我有这个: 在此输入图像描述

我有一个 NSDictionary,其键值包含一串时间。我将键值存储在 NSArray 中。

我使用 titleForHeaderInSection 而不是 viewForHeaderInSection。

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{   
    return [schedule objectAtIndex:section];
}
Run Code Online (Sandbox Code Playgroud)

但是,节标题始终向左对齐。我可以使用 viewForHeaderInSection 的 UIView 将其填充到我喜欢的位置,但是有什么方法可以为方法 titleForHeaderInSection 做到这一点吗?

xcode objective-c ios

6
推荐指数
1
解决办法
3352
查看次数

标签 统计

ios ×3

iphone ×2

objective-c ×2

ios7 ×1

separator ×1

uitableview ×1

xcode ×1