NSDateFormatter

发布于 2024-10-04 01:15:27 字数 518 浏览 0 评论 0原文

我正在尝试创建一个类似于 iPhone 上的 Notes 应用程序中的 TableViewCell 。标题位于左侧,时间位于披露者指示符旁边的右侧。

一个 tableView 看起来像这样。我知道我必须使用这样的东西

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat: @"HH:mm zz"];

NSDate *dateTmp;
dateTmp = [[self.Notes objectAtIndex:indexPath.row ]objectForKey:@"CDate"];
cell.detailTextLabel.text = [dateFormat stringFromDate: dateTmp];

http://cl.ly/3Mpj

我将如何移动详细信息标签到顶部旁边的披露者指标?

I'm trying to create a TableViewCell like the one in the Notes app on the iPhone. Have the title on the left and the time on the right next to the discloser indecator.

A tableView which would look like that. I know I have to use something like this

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat: @"HH:mm zz"];

NSDate *dateTmp;
dateTmp = [[self.Notes objectAtIndex:indexPath.row ]objectForKey:@"CDate"];
cell.detailTextLabel.text = [dateFormat stringFromDate: dateTmp];

http://cl.ly/3Mpj

How would I move the detail label to the top next the the discloser indecator?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨后彩虹 2024-10-11 01:15:27

使用应该创建一个自定义单元格...
相应地放置两个按钮...
在这里我就是这样做的...
替代文本

Use should create a custom cell...
Place two buttons accordingly...
Here i did like this...
alt text

菩提树下叶撕阳。 2024-10-11 01:15:27

我想你还是希望时间成为细节标签?如果是这样,第一个选项可以工作..

有几个选项:

您可以尝试简单地使用 cell.detailTextLabel.textAlignment = UITextAlignmentRight 之类的内容设置detailLabel的文本对齐方式,

或者如果这不适合您的需要,您始终可以子类化 UITableViewCell 并根据您需要的位置创建自己的单元格。

编辑:在重读您的帖子时,您希望时间标签与名称位于同一“行”上,并且位于右侧。为此,您可能需要使用自定义 UITableViewCell ,这样您就可以按照您想要的方式放置和格式化标签。

I think you still want the time to be the detail label? If so the first option could work..

There are a few options:

You could try to simply set the detailLabel's text alignment with something like cell.detailTextLabel.textAlignment = UITextAlignmentRight

Or if this doesn't fit your needs, you can always subclass UITableViewCell and create your own cell with placement however you need it.

Edit: on rereading your post, you want the time Label to be on the same "row" as the name, and on the right..for this you are probably going to want to use a custom UITableViewCell, that way you can place and format your labels exactly how you want them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文