I am relatively new to iPhone development ,i tried to add uitableview to scroll view but it is showing Sigabart error then i added programatically and added uitableviewdelegate and uitableview data source to it and give delegate as self and add ‘noOfRowsInSection’ method the delgate methods are not beeing called.can any one help me.
@interface Class : UIViewController<UITableViewDelegate,UITableViewDataSource> {
UITableView *table;
UIScrollView *scrView;
NSArray *array;
}
@property (nonatomic, retain) IBOutlet UIScrollView *scrView;
@end
here is my implementation
- (void)viewDidload
{
array = [[NSArray alloc]initWithObjects:@"harsha",@"theja",@"pandu", nil];
[super viewDidUnload];
table = [[UITableView alloc]initWithFrame:CGRectMake(0, 260, 360, 220)];
[self.view addSubview:table];
table.delegate = self ;
}
- (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];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = [array objectAtIndex:indexPath.row];
return cell;
}
@end
I am adding the scroll view though Interface builder but i am doing table view progra matically the tabl view is shown on the screen but the methods are not beeing called
1st: you are using viewDidUnload instead of viewDidLoad,
2nd: add
tableview.dataSource = selfand implement the datasource delegate methods =)you are using the delegate instead of the datasource =)