simple TableView not displaying data
I am a beginner, learning how to do tableViews. I followed everything in
my book, but my table View is not being populated. Shouldn't it display
the word "Testing" for three rows here? My tableview Outlet is connected,
and I enabled the delegate and datasource. What am I missing here? After
all, I am following a book.
#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];
}
here is my .h file
#import <UIKit/UIKit.h>
@interface CLViewController : UIViewController <UITableViewDelegate,
UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@end
No comments:
Post a Comment