我正在构建一个小应用程序,我在一个TableView中显示一个数组。问题是我不想使用UITableViewController,我只想使用ViewController。当我在模拟器中运行应用程序时,它不显示数组。这里是代码:问题与UITableView
.h
@interface ViewController : UIViewController{
IBOutlet UITableView *table;
NSArray *array;
}
.m
- (void)viewDidLoad
{
[super viewDidLoad];
array =[NSArray arrayWithObjects:@"iPad",@"iTV" ,nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)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];
return cell;
}
请不要回答这个说法,我必须使用UITableViewController。我知道可以在没有它的情况下管理它,只需使用ViewController即可。不管怎样,谢谢你!
谢谢你,它的现在可以! – Adri 2012-01-29 19:22:54
所以......我认为它已经完成了,但还没有结束。我不知道如何做什么你说连接委托和数据源的文件的所有者,请如果你能解释这部分我将不胜感激! – Adri 2012-01-30 19:19:05
如果可以,请回答。 – Adri 2012-01-30 22:26:02