Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone textLabel和detailTextLabel向右对齐_Iphone_Objective C_Ios_Uitableview - Fatal编程技术网

Iphone textLabel和detailTextLabel向右对齐

Iphone textLabel和detailTextLabel向右对齐,iphone,objective-c,ios,uitableview,Iphone,Objective C,Ios,Uitableview,我有以下代码: cell.textLabel.text = [arrBugs objectAtIndex:indexPath.row]; cell.detailTextLabel.text = @"just a text"; cell.imageView.image = [UIImage imageNamed:[arrImages objectAtIndex:indexPath.row]]; cell.textLabel.textAlignment = UITextAlignmentRight;

我有以下代码:

cell.textLabel.text = [arrBugs objectAtIndex:indexPath.row];
cell.detailTextLabel.text = @"just a text";
cell.imageView.image = [UIImage imageNamed:[arrImages objectAtIndex:indexPath.row]];
cell.textLabel.textAlignment = UITextAlignmentRight;
cell.detailTextLabel.textAlignment = UITextAlignmentRight;
单元格.detailTextLabel.text
不存在时,
文本标签
向右对齐没有任何问题,但一旦我添加
单元格.detailTextLabel.text
它们都向左对齐。如何解决此问题?我希望他们两个都向右对齐


我不使用自定义表格视图单元格。

对于此类问题,了解单元格的设置方式非常重要: 在序列图像板编辑器中创建单元时,您无法在稍后的代码中更改所有设置。 只有在代码中创建单元格时,才能更改所有设置

但是,请回复您的单元格在创建时的设置

完成了一个简单的项目,单元格的样式为“right detail”,我只使用两个文本赋值没有问题


可能是您正试图在每个单元格的基础上更改对齐方式

您也可以通过子类化UITableViewCell来创建自己的UITableViewCell,然后创建自己的xib文件,并将标签放置在您想要的位置。 创建行时,需要加载新创建的xib文件。
这里有一个教程:

当我只写cell.textlab.text=@“text”时,您如何知道它在单元格中没有文本的情况下工作;cell.textLabel.textAlignment=UITextAlignmentRight;它起作用了。但是当我添加cell.detailTextLabel.text=@“只是一个文本”;cell.detailTextLabel.textAlignment=UITextAlignmentRight;突然,单元格向左对齐,而不是向右对齐。UITextAlignment不推荐使用。对不起,我不明白你在这里说的话。可以将textLabel和detailTextLabel都对齐到单元格右侧吗?嗨,Yossi,没问题。您可以这样做,但只能在自定义单元格中进行,当您使用预定义的单元格并且希望更改太多时,它将不起作用。我可以寄给你一个简单的样品解决方案,如果你只想有主要的和详细的权利对齐。你需要这个吗?嗨,Yossi,我不能在这里放一个zip文件,所以请转到那里,你可以下载一个快照并查看部分源代码。