原谅我对iPhone编程的无知,因为我是一个新手。 我正在做一个应用程序,其中init view controller是用于显示数据的UITable视图控制器,另一个用于输入数据的View controller。UITableviewcontroller重新加载数据问题
我的问题是,当我输入一个新的数据,它不会出现在UItable控制器,我试图重新加载数据[self.tableview reloadData]
在viewDidLoad
但数据不会重新加载,因为我使用自定义委托我尝试写[self.tableview reloadData]
作为我的自定义代理的最后一行,但它也没有工作,我尝试使用viewDidAppear
,但那也不起作用。
这里是代码:
MainViewController.m(TableView中)
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Initializing conference array");
conferenceData = [[NSMutableArray alloc]init];
SavingData *loadData = [[SavingData alloc]init];
NSLog(@"Loading the file then fill it in an array");
conferenceData = [loadData LoadDataArray];
NSLog(@"Done Initializing conference array");
[self.tableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [conferenceData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
NSLog(@"writing data in cell number %i",indexPath.row);
cell.textLabel.text = [[conferenceData objectAtIndex:indexPath.row]name];
return cell;
}
// Implementing the adding delegate
-(void) setInformation:(Adding *)controller withObject:(Conference *)info
{
Conference *confer = info; //Temprory Conference object to store data
SavingData *saveToFile = [[SavingData alloc]init];
if ([saveToFile SavingDataWithObject:confer]) //Calling SavingDataWithObject method and check if the save operation return true or false
{
NSLog(@"Done Saving !!");
}
[self.navigationController popToRootViewControllerAnimated:YES]; // after saving return to the main window
NSLog(@"Should be popped right now");
}
非常感谢你提前