小编use*_*693的帖子

使用换行符附加NSAttributedString会返回格式错误的属性字符串

我正在使用NSMutableAttributedStringNSAttributedString以两种不同的字体大小显示标签文本.我的方法是:

NSMutableAttributedString *muAtrStr = [[NSMutableAttributedString alloc]initWithString:@"2"];
NSAttributedString *atrStr = [[NSAttributedString alloc]initWithString:@"days" attributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:8]}];
[muAtrStr appendAttributedString:atrStr];
Run Code Online (Sandbox Code Playgroud)

它返回一个归因字符串,字体大小为12,字符大小为"2",字体大小为8.

但是,另一种情况是在2之后添加换行符.我使用以下代码:

NSMutableAttributedString *muAtrStr = [[NSMutableAttributedString alloc]initWithString:@"2"];
NSAttributedString *atrStr = [[NSAttributedString alloc]initWithString:@"\ndays" attributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:8]}];
[muAtrStr appendAttributedString:atrStr];
Run Code Online (Sandbox Code Playgroud)

此时属性字符串应用全文的属性.我得到一个字体大小为8的"2 \ndays"的属性字符串.

objective-c nsattributedstring ios

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

滚动表格视图时,自定义UITableView页脚不会锁定在底部

我检查了所有这些 UITableView,让页脚停留在屏幕的底部?

tableFooterView属性不会修复表视图底部的页脚

iOS - viewForFooterInSection坚持UITableView的底部

在UITableView中实现页脚的正确方法

类似的问题,但不幸的是我的问题没有解决.

我必须使用里面的按钮实现自定义页眉和页脚视图.我用.nib文件创建了单独的UIView的子类.在我的视图控制器中,我正在调用这些方法来为页眉和页脚视图注册nib.

- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    CustomTableHeaderView *view = [CustomTableHeaderView header];
    view.delegate = self; //setting delegate to receive callbacks as the buttons inside the view are pressed
    return view;
}

- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    CustomTableFooterView *view = [CustomTableFooterView footer];
    view.delegate = self;
    return view;
}
Run Code Online (Sandbox Code Playgroud)

自定义视图中的类方法注册.nib文件并返回视图的位置.然而,实施是;

+ (CustomTableHeaderView*)header
{
    return [[[NSBundle mainBundle]loadNibNamed:@"CustomTableHeaderView" owner:nil options:nil]objectAtIndex:0];
}
Run Code Online (Sandbox Code Playgroud)

页脚的类似实现.

问题是当表格视图滚动时,页脚视图不会锁定在底部.也就是说,当视图内部有更多行时,页脚视图会隐藏,并在所有行向下滚动直到结束时显示.我想锁定视图底部的页脚视图,无论有多少行可以滚动.标题视图已完全由此实现实现,因为在滚动行时它被锁定在顶部,但页脚视图随行滚动.

我也试过了self.tableview.tablefooterview属性,但它也没有帮助.

cocoa-touch objective-c uitableview ios

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