<i id='OxXyw'><tr id='OxXyw'><dt id='OxXyw'><q id='OxXyw'><span id='OxXyw'><b id='OxXyw'><form id='OxXyw'><ins id='OxXyw'></ins><ul id='OxXyw'></ul><sub id='OxXyw'></sub></form><legend id='OxXyw'></legend><bdo id='OxXyw'><pre id='OxXyw'><center id='OxXyw'></center></pre></bdo></b><th id='OxXyw'></th></span></q></dt></tr></i><div id='OxXyw'><tfoot id='OxXyw'></tfoot><dl id='OxXyw'><fieldset id='OxXyw'></fieldset></dl></div>
      <bdo id='OxXyw'></bdo><ul id='OxXyw'></ul>
  • <legend id='OxXyw'><style id='OxXyw'><dir id='OxXyw'><q id='OxXyw'></q></dir></style></legend>

      <tfoot id='OxXyw'></tfoot>
      1. <small id='OxXyw'></small><noframes id='OxXyw'>

        UITableViewCell中的文本居中对齐问题

        时间:2023-10-02

          <legend id='dxT31'><style id='dxT31'><dir id='dxT31'><q id='dxT31'></q></dir></style></legend>

          <i id='dxT31'><tr id='dxT31'><dt id='dxT31'><q id='dxT31'><span id='dxT31'><b id='dxT31'><form id='dxT31'><ins id='dxT31'></ins><ul id='dxT31'></ul><sub id='dxT31'></sub></form><legend id='dxT31'></legend><bdo id='dxT31'><pre id='dxT31'><center id='dxT31'></center></pre></bdo></b><th id='dxT31'></th></span></q></dt></tr></i><div id='dxT31'><tfoot id='dxT31'></tfoot><dl id='dxT31'><fieldset id='dxT31'></fieldset></dl></div>

          <small id='dxT31'></small><noframes id='dxT31'>

            • <bdo id='dxT31'></bdo><ul id='dxT31'></ul>

                <tbody id='dxT31'></tbody>
                  <tfoot id='dxT31'></tfoot>
                  本文介绍了UITableViewCell中的文本居中对齐问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我对 Objective-C 和 iPhone 开发有点陌生,在尝试将文本置于表格单元格中时遇到了问题.我搜索了谷歌,但解决方案是针对已修复的旧 SDK 错误,这些对我不起作用.

                  I'm kinda new to Objective-C and iPhone development and I've come across a problem when trying to center the text in a table cell. I've searched google but the solutions are for an old SDK bug that has been fixed and these don't work for me.

                  一些代码:

                  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
                  
                      cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
                      if (cell == nil) {
                          cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
                      }
                  
                      cell.textLabel.text = @"Please center me";
                      cell.textLabel.textAlignment = UITextAlignmentCenter;
                      return cell;
                  }
                  

                  上面的文字没有居中.

                  我也试过 willDisplayCell 方法:

                  I have also tried the willDisplayCell method:

                  - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
                      cell.textLabel.textAlignment = UITextAlignmentCenter;
                  }
                  

                  我已经尝试了一些旧发布的解决方案:

                  and I've tried some of the old posted solutions:

                  UILabel* label = [[[cell contentView] subviews] objectAtIndex:0];
                  label.textAlignment = UITextAlignmentCenter;
                  return cell;
                  

                  这些都不会对文本对齐产生任何影响.我的想法已经用完了,任何帮助将不胜感激.

                  None of these have any effect on the text alignment. I have run out of idea's any help would be most appreciated.

                  提前干杯.

                  推荐答案

                  不知道它是否对你的具体问题有帮助,但是如果你使用 initWithStyle:UITableViewCellStyleDefault 确实可以工作代码>

                  Don't know if it helps your specific problem, however UITextAlignmentCenter does work if you use initWithStyle:UITableViewCellStyleDefault

                  这篇关于UITableViewCell中的文本居中对齐问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 iOS 4 中将 UIView 内容保存为内部图像的实际大小(即放大内容以进行保存) 下一篇:iOS 下载并保存 HTML 文件

                  相关文章

                  <tfoot id='6XYtf'></tfoot>
                • <small id='6XYtf'></small><noframes id='6XYtf'>

                  <legend id='6XYtf'><style id='6XYtf'><dir id='6XYtf'><q id='6XYtf'></q></dir></style></legend>
                • <i id='6XYtf'><tr id='6XYtf'><dt id='6XYtf'><q id='6XYtf'><span id='6XYtf'><b id='6XYtf'><form id='6XYtf'><ins id='6XYtf'></ins><ul id='6XYtf'></ul><sub id='6XYtf'></sub></form><legend id='6XYtf'></legend><bdo id='6XYtf'><pre id='6XYtf'><center id='6XYtf'></center></pre></bdo></b><th id='6XYtf'></th></span></q></dt></tr></i><div id='6XYtf'><tfoot id='6XYtf'></tfoot><dl id='6XYtf'><fieldset id='6XYtf'></fieldset></dl></div>

                        <bdo id='6XYtf'></bdo><ul id='6XYtf'></ul>