2011-03-08 2 views
1

좋아, 테이블 뷰에 행을 추가하려고합니다. 나는 틀린 일을해야만한다. 배열에 추가 오전, 새 배열을 사용하여 UITableView 새로 고치려면 누락 된 함수가 있나요? 나는 wiled 거위 추적으로 나를 리드 사이트를 둘러 보았다하고있는 tableview하지만 추가 연구에 배열을 밀어 대해 뭔가를 본 것처럼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 참조 서를 참조하십시오.

관련 문제