UITableView внутри UIViewController

Как я могу использовать внутри ? Ниже приведен пример того, что я пытаюсь сделать (, за исключением того, что это всего лишь UITableviewв моей раскадровке ):

UITableView inside a UIViewController

. Я понял, что мне нужно добавить делегата и источник данных в мой заголовок:

//MyViewController.h
@interface MyViewController : UIViewController 

В моем файле реализации я добавил необходимые методы:

//MyViewController.m

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"cellForRowAtIndexPath");

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FileCell"];

    NSLog(@"cellForRowAtIndexPath");
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSArray *fileListAct = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil];

    cell.textLabel.text = [NSString stringWithFormat:@"%@",[fileListAct objectAtIndex:indexPath.row]];

    return cell;
}

delegate, datasourceи UITableViewвсе подключены к моей раскадровке:

UITableView Delegate and DataSource in Interface Builder Connections Outlet

Я не могу заставить TableView загружать содержимое, которое Я говорю это. Он всегда выходит пустым. Почему TableView не заполняет содержимое, которое я указал в методе cellForRowAtIndexPath? Что мне здесь не хватает?

9
задан Sam Spencer 26 June 2013 в 20:30
поделиться