Last week i have downloaded Xcode 4.2, so when i started building apps i\'ve tried to add an UITableView
to one of my projects (as normal as i have been doing s
in your .h file, add the following:
@interface YourClass: UIViewController <**UITableViewDataSource, UITableViewDelegate**>
right-click (or ctrl-click) and drag from your tableView to the File's Owner twice. Once, select "delegate", and once select "dataSource".
Then, in your .m file, you need to implement the following:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{return 1;}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{return someNumber;}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
[[cell textLabel] setText:yourText];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//do what you want to with the information at indexPath.row
}
That should get you a working tableView.