Quote:
Originally Posted by simpsonaty
It would be much easier to use IB to create your UITableView and populate the array. You can start populating the NSArray in the - (void)viewDidLoad method. Don't forget to add the array in the .h header file.
Code:
- (void)viewDidLoad {
myArray = [[NSArray alloc] initWithObjects:@"1", @"2", @"3", nil];
[super viewDidLoad];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell...
cell.text = [myArray objectAtIndex:indexPath.row];
return cell;
}
|
Thank you for the answer. I have tried using ib and i got it working. however, the [self.tableView reloadData] doesn't seem to work. i know that my array is not nil and it changed before i called [self.tableView reloadData].
also i have added a toolbar to the bottom of the screen but now my tableview is blocked by the toolbar. is there anyway to change the frame size of my tableview? i have tried self.tableView.frame = myNewFrame;
Happy Holidays!