![](/img/trans.png)
[英]How to go from one view controller to another view controller through tab bar controller when Click a button in the first view controller
[英]implement prototype cell when I click a button in another view Controller
我的程序有一个视图控制器和一个tableView控制器。 我打算每次单击viewController中的按钮时,以当前时间升级tableview单元。
ViewController.m
@interface ViewController ()
@property(nonatomic,strong) Brain* brain;
@property(nonatomic,readonly)TimeTableController* tableControl;
@end
- (void)viewDidLoad
{
[super viewDidLoad];
_brain=[[Brain alloc] init];
_tableControl=[[TimeTableController alloc] init];
}
- (IBAction)actionTime:(id)sender {
[self.tableControl.entryTime addObject:[self.brain currentTime]];
}
timeTableController.h
@property (strong, nonatomic) IBOutlet UITableView *timeTable;
@property(nonatomic,strong) NSMutableArray* entryTime;
timeTableController.m
- (void)viewDidLoad
{
[super viewDidLoad];
_entryTime=[[NSMutableArray alloc] init];
_timeTable=[[UITableView alloc] init];
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{ if(!_entryTime) return 0;
else
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_entryTime count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ ...
self.cell.timeLabel.text = [NSString stringWithFormat:@"%@",[self.entryTime objectAtIndex:[indexPath row]]];
}
[self.tableControl.timeTable reloadData];
return cell;
}
但是,当我按下按钮时,什么也没发生。 有人可以帮我解决吗?
你在哪
@property(nonatomic,strong) NSString* timeLabel;
?
然后,在将标签放置在位于xib文件中的自定义单元格中之后,不要忘记将其连接到xib文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.