我有一個表,我想在那裏顯示一些文本;但我不能,我不知道爲什麼。我的應用程序是基於視圖的應用程序,我不想爲表視圖控制器進行更改。下面的代碼:如何在UITableView中顯示文本
.h
{
NSArray *array;
IBOutlet UITableView *table;
}
.m
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [array count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.textLabel.text = [array objectAtIndex:indexPath.row];
// Configure the cell
return cell;
}
請幫助我,因爲我試圖解決這個問題,我不知道什麼是錯的,爲什麼表不顯示陣!
謝謝!
您是否連接了數據源和委託? – Louie 2012-01-31 20:53:25
我如何連接它? – Adri 2012-01-31 20:55:18