Я начинаю учиться, как делать tableViews. Я следил за всем в моей книге, но мой стол View не заселен. Разве это не означает, что здесь отображается слово «Тестирование» для трех строк? Моя таблицаview Outlet подключена, и я включил делегат и источник данных. Что мне здесь не хватает? В конце концов, я следую за книгой.простой TableView не отображает данные
#pragma mark UITableViewDataSource Methods
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@"cell"];
if(nil == cell)
{
cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}
cell.textLabel.text = @"Testing";
return cell;
}
-(NSInteger)tableView: (UITableView *)tv numberofRowsInSection:(NSInteger)section
{
return 3;
}
#pragma mark UITableViewDelegate Methods
-(void)tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tv deselectRowAtIndexPath:indexPath animated:YES];
}
вот мой .h файл
#import <UIKit/UIKit.h>
@interface CLViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@end
Вы реализовали метод '- (NSInteger) метода OfSectionsInTableView: (UITableView *) tableView'? –
@esker: Вам не нужно реализовывать этот метод (если у вас есть один раздел), метод по умолчанию возвращает '1'. –
О, не знал об этом, хорошо знать. –