![](/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.