拔掉我的頭髮。我做了與表視圖這麼多的應用程序和一直在尋找我過去的應用程序,但由於某些原因,這表視圖是太固執,顯示什麼...TableView不會加載任何數據
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.delegate = self;
self.tableView.datasource = self;
[_myArray addObject:@"Hi"];
[_myArray addObject:@"Hello"];
[_myArray addObject:@"Bye"];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section
{
return [_myArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
NSString *currentItem = [_myArray objectAtIndex:indexPath.row];
cell.textLabel.text = @"Hi";
// Configure the cell...
return cell;
}
所以基本上什麼也不顯示了我。即使我設置委託,並在.h文件中獲得了表視圖委託和數據源,表視圖仍然是空白的。
您需要提供更多信息,您是否正確實施了numberOfRowsInSection,numberOfSectionsInTableView等? _myArray中的數據是什麼?如果正確連接了一切,你是否在使用XIB? –
嗯我不試圖從數組中加載數據,我只想在我的單元上的文本... – doc92606
我會發布更多的代碼。 – doc92606