0

テーブル セル内のテキストを左右に揃える必要があります。アプリケーションで plist の選択に従って 2 つの plist を使用しました。テーブル セル内のテキストを揃える必要があります。

そのために次のコードを試します

if ([app.currentPlist isEqualToString:@"Accounting.plist"]) {
    cell.textAlignment=UITextAlignmentLeft;            
} else {
    cell.textAlignment=UITextAlignmentRight;           
}
4

3 に答える 3

2

UITextAlignmentRightは非推奨です。NSTextAlignmentLeft代わりに使用してください

したがって、コードは次のようになります- cell.textLabel.textAlignment = NSTextAlignmentLeft;

于 2014-08-30T15:10:23.160 に答える
2

UITableViewCelltextAlignmentプロパティを持っていません。セルのテキスト ラベルに設定する必要があります。

- (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;
}
于 2011-08-23T13:57:29.873 に答える
1

迅速にそれは

cell.textLabel.textAlignment = NSTextAlignment.Right
于 2014-10-29T12:13:31.777 に答える