Как я могу использовать uitableview внутри uiviewcontroller ? Ниже приведен пример того, что я пытаюсь сделать (, за исключением того, что это всего лишь UITableview
в моей раскадровке ):
. Я понял, что мне нужно добавить делегата и источник данных в мой заголовок:
//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
все подключены к моей раскадровке:
Я не могу заставить TableView загружать содержимое, которое Я говорю это. Он всегда выходит пустым. Почему TableView не заполняет содержимое, которое я указал в методе cellForRowAtIndexPath? Что мне здесь не хватает?