2011-03-08 61 views
1

好吧,我試圖向我的tableview添加一行。我一定是做錯了。我正在添加到數組中,是否有一個我失蹤的函數來刷新使用新數組的UITableView?正如我在看着我在工地附近,並看到一些關於推動數組的tableview,但進一步的研究領先進入一個wiled鵝追iOS使用數組添加到UITableView

#import "RootViewController.h" 
#import "DetailViewController.h" 
@implementation RootViewController 
@synthesize toolbar; 
@synthesize window; 

#pragma mark - 
#pragma mark View lifecycle 


- (void)viewDidLoad { 
    //theArray = [[NSArray alloc] initWithObjects:@"Apple",nil]; 
    theArray = [[NSMutableArray alloc] init]; 


    [super viewDidLoad]; 

    [window addSubview:[navigationController view]]; 
    [window addSubview:toolbar]; 
    [window makeKeyAndVisible]; 
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 
    // self.navigationItem.rightBarButtonItem = self.editButtonItem; 
} 



#pragma mark - 
#pragma mark Table view delegate 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    NSString *selectedTask = [theArray objectAtIndex:indexPath.row]; 
    DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]]; 
    dvController.selectedTask = selectedTask; 
    [self.navigationController pushViewController:dvController animated:YES]; 
    [dvController release]; 
    dvController = nil; 

} 



- (void)didReceiveMemoryWarning { 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 

    // Relinquish ownership any cached data, images, etc that aren't in use. 
} 

- (void)viewDidUnload { 
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand. 
    // For example: self.myOutlet = nil; 
} 


- (void)dealloc { 
    [super dealloc]; 
} 


@end 

你的幫助是極大的讚賞。

回答

3

假設您已經正確定義了所有UITableViewDataSource方法,那麼您可能只需要在UITableView上調用reloadData。有關reloadData方法的詳細信息,請參閱UITableView參考。