我正在开发一个教育任务管理器,我想在单元格的字幕部分添加一个时间戳。我已经正确编码了任务的标题,但我想用创建任务时的时间戳替换副标题。
我想把它说字幕的地方变成时间戳
有人可以帮我吗?只需在下面评论我需要添加到附加到此 TableView 的控制器的代码。下面是我的 ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITableViewDataSource>
-(IBAction)add:(UIBarButtonItem *)sender;
@property (nonatomic, strong) NSMutableArray *tasksArray;
@property (nonatomic, strong) IBOutlet UITableView *tasksTable;
@end
这是我的 ViewController.m
@interface ViewController ()
@end
@implementation ViewController
@synthesize tasksArray = _tasksArray;
@synthesize tasksTable = _tasksTable;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"Test");
self.tasksArray = [[NSMutableArray alloc]init];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(IBAction)add:(UIBarButtonItem *)sender
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Enter the task name" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *buttonTile = [alertView buttonTitleAtIndex:buttonIndex];
if ([buttonTile isEqualToString:@"Add"]) {
[self.tasksArray addObject:[alertView textFieldAtIndex:0].text];
[self.tasksTable reloadData];
}
}
#pragma mark
#pragma table view
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.tasksArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [self.tasksArray objectAtIndex:indexPath.row];
return cell;
}
@end
我是 StackOverFlow 的新手,所以如果我的帖子很糟糕,请不要评判:p 哈哈!干杯,请帮助我!