在我的應用程序中,五個標籤欄正在使用。在第五個標籤中有一個表視圖在那裏im檢索和數組並顯示在表視圖。數組內容在NSLog.But中正確顯示只有陣列中的第一個內容顯示在單元格中。任何人都可以幫助我如何解決這個問題,請.. 下面是我使用的代碼,任何人都可以給我一個手,哪裏會出錯,請..表重新加載數據不起作用
這裏是其中IM添加內容
-(IBAction)Done
{
NSString *message = [df stringFromDate:itemDate];
NSLog(@"message1234 %@",message);
dates= [[NSMutableArray alloc] init];
NSUserDefaults *currentDefaults7 = [NSUserDefaults standardUserDefaults];
NSData *dataRepresentingSavedArray7 = [currentDefaults7 objectForKey:@"datingg"];
NSMutableArray *oldSavedArray7 = [NSKeyedUnarchiver unarchiveObjectWithData:dataRepresentingSavedArray7];
if(dates!=nil)
{
dates = [[NSMutableArray alloc] initWithArray:oldSavedArray7];
}
[dates addObject:message];
NSUserDefaults *currentDefaults3 = [NSUserDefaults standardUserDefaults];
[currentDefaults3 setObject:[NSKeyedArchiver archivedDataWithRootObject:dates] forKey:@"datingg"];
[currentDefaults3 synchronize];
NSLog(@"%@dates ate getting heree",dates);
這裏是IM以便在檢索內容(第五選項卡)
- (void)viewWillAppear:(BOOL)animated
{
NSLog(@"ddddd");
NSUserDefaults *currentDefaults = [NSUserDefaults standardUserDefaults];
NSData *dataRepresentingSavedArray = [currentDefaults objectForKey:@"datingg"];
NSMutableArray *oldSavedArray = [NSKeyedUnarchiver unarchiveObjectWithData:dataRepresentingSavedArray];
datedisplay = [[NSMutableArray alloc] initWithArray:oldSavedArray];
NSLog(@"%@",datedisplay);
[self.tab reloadData];
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
//#warning Potentially incomplete method implementation.
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//#warning Incomplete method implementation.
// Return the number of rows in the section.
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if(i<[datedisplay count])
{
// Configure the cell...
cell.textLabel.text=[datedisplay objectAtIndex:i];
i++;
}
[self.tab reloadData];
return cell;
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
*/
}
@end
In NSLog it is showing
Reminder[6448:207] (
"02 04-12",
"02 03-12",
"03 04-20"
)
![enter image description here][1]
非常感謝後4 minutes.Please我會接受它告訴我,爲什麼它沒有顯示內容,無需重新發布應用程序 – Senorina
退出並重新,或回到主屏幕並重新進入應用程序? – jrturton
@ jrturton,即按主頁按鈕,並再次採取app.also當再次運行在模擬器它顯示 – Senorina