Ios 将UITableView方向更改为从右向左
我开发了一个iOS应用程序,我的母语是波斯语(一种从右到左的语言)。如何在iOS编程中将UITableView方向更改为从右向左 具有RTL方向的UITableView具有:Ios 将UITableView方向更改为从右向左,ios,swift,uitableview,right-to-left,Ios,Swift,Uitableview,Right To Left,我开发了一个iOS应用程序,我的母语是波斯语(一种从右到左的语言)。如何在iOS编程中将UITableView方向更改为从右向左 具有RTL方向的UITableView具有: 图标在右边 TableCell详细信息和按钮位于左侧 TableView页眉和页脚右对齐 像这样: 有什么UI或编程方法可以做到这一点吗?据我所知,从iOS8开始,它将自动变为从右向左。您也可以尝试这样做 func tableView(tableView: UITableView, cellForRowAtIndex
- 图标在右边
- TableCell详细信息和按钮位于左侧
- TableView页眉和页脚右对齐
有什么UI或编程方法可以做到这一点吗?据我所知,从iOS8开始,它将自动变为从右向左。您也可以尝试这样做
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = myTableView.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell
cell.textLabel?.textAlignment = .Right
cell.textLabel?.text = goalsArray[indexPath.row]
return cell
}
使用
nslayouttributereading
和nslayouttributetrailing
而不是nslayouttributeft
和nslayouttributelight
构建视图约束
您的视图方向将与应用程序的语言方向相同
在Swift 3上试试这个
tableView.semanticContentAttribute = .forceRightToLeft
或者在情节提要单元属性(语义下拉列表)中选择“从右向左强制”
对我来说,这种方法奏效了
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier)! as UITableViewCell
//cell.myView.backgroundColor = self.colors[indexPath.row]
cell.textLabel?.text =
"\((self.FAQs?[indexPath.row].Question)!)"
cell.textLabel?.textAlignment = .right
return cell
}