Iphone 对齐UITableView中的文本';页脚

Iphone 对齐UITableView中的文本';页脚,iphone,objective-c,uitableview,Iphone,Objective C,Uitableview,我正在使用 - (NSString *)tableView:(UITableView *)tv titleForFooterInSection:(NSInteger)section { if (section == 1) { return @ "Some text \r\n" "\r\n" "1. Point 1\r\n " "2. Point 2\r\n" "3. Point 3"; } return @""; } 用于一组单元格的页

我正在使用

- (NSString *)tableView:(UITableView *)tv titleForFooterInSection:(NSInteger)section
{
if (section == 1)
{
    return @
    "Some text  \r\n"
    "\r\n"
    "1. Point 1\r\n "
    "2. Point 2\r\n"
    "3. Point 3";
}
    return @"";
}

用于一组单元格的页脚。它工作得很好,但我想将文本向左对齐(以帮助外观)。我知道您可以使用
viewforfooterInstitution
创建视图/ui标签,但这似乎是一个很难解决的问题。有什么方法可以对齐它吗?

tableView:viewforfooter设置:
不是一个解决方法

苹果公司通常会给你两种选择,简易方式和手动方式

如果简单的方法(
tableView:titleforfooterInstition:
)没有达到您想要的效果,那么您可以通过添加自己的视图来获得最大的灵活性

实际上,您只需在
tableView:viewForFooterInstitution:


应该非常简单。

如果您的tableview很短,那么您也可以这样写:

-(void)viewDidLayoutSubviews 
{
    for (int section = 0; section < [self.tableView numberOfSections]; section++)
    {
        [self.tableView footerViewForSection:section].textLabel.textAlignment = NSTextAlignmentRight;
    }
}
-(void)ViewDidLayoutSubView
{
对于(int section=0;section<[self.tableView numberOfSections];section++)
{
[self.tableView footerViewForSection:section].textLabel.textAlignment=NSTextAlignmentRight;
}
}

是的,我意识到这并不难,但因为我想把文本向左对齐,所以我想我会问。
override func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) {
    let footerView = view as! UITableViewHeaderFooterView        
    footerView.textLabel?.textAlignment = .center //or whatever you want
}