NSDateFormatter
我正在尝试创建一个类似于 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];
我将如何移动详细信息标签到顶部旁边的披露者指标?
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];
How would I move the detail label to the top next the the discloser indecator?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用应该创建一个自定义单元格...
相应地放置两个按钮...
在这里我就是这样做的...
Use should create a custom cell...
Place two buttons accordingly...
Here i did like this...
我想你还是希望时间成为细节标签?如果是这样,第一个选项可以工作..
有几个选项:
您可以尝试简单地使用
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.