- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我必须将表格单元格中的文本左右对齐。我在我的应用程序中使用了两个 plist根据 plist 选择,我必须在表格单元格中对齐我的文本。
我尝试使用下面的代码
if ([app.currentPlist isEqualToString:@"Accounting.plist"]) {
cell.textAlignment=UITextAlignmentLeft;
} else {
cell.textAlignment=UITextAlignmentRight;
}
最佳答案
UITableViewCell
没有 textAlignment
属性。您必须在单元格的文本标签上设置它:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"Something";
if([app.currentPlist isEqualToString:@"Accounting.plist"])
{
cell.textLabel.textAlignment=UITextAlignmentLeft;
}
else
{
cell.textLabel.textAlignment=UITextAlignmentRight;
}
return cell;
}
关于iphone - 如何使用 UITextAlignment 将 UITableViewCell 中的文本在 Swift 中左右对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7162126/
我正在使用 Xcode 5.0.2 并在尝试编译我的 Objective-C 代码时收到以下警告: **Implicit conversion from enumeration type 'NSTex
如何以编程方式对齐 UItextView?我不需要 label.textAlignment = UITextAlignmentCenter; 但我想准确地选择对齐方式。 最佳答案 setTextCon
我有一个在 iOS6 下编写的项目,它与 iOS5 或 plus 兼容。最近我重新打开项目,我有这个非常奇怪的错误 但在我所有的其他项目中,这条线工作正常。有什么问题? 谢谢! 最佳答案 旧的 UIT
我在 Xcode5 上为 ios7 编码,编译器显示这个错误:从枚举类型隐式转换:NSTextAlignment 枚举 NSTextAlignment 到不同的枚举 UITextAlignment -
似乎 UITextAlignmentCenter 在 iOS 6 中被弃用了。 我仍在使用它并且运行良好,但它会发出警告。 我该如何解决这个问题? label.textAlignment = UITe
在为 iOS6 编译我的应用程序时,我收到以下弃用消息: 从 iOS 6 及更高版本开始,UITextAlignmentCenter 已弃用。请改用 NSTextAlignmentCenter。 我认
我必须将表格单元格中的文本左右对齐。我在我的应用程序中使用了两个 plist根据 plist 选择,我必须在表格单元格中对齐我的文本。 我尝试使用下面的代码 if ([app.currentPlist
我是一名优秀的程序员,十分优秀!