Sunday, June 27, 2010

Table View Methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return /*no of sections*/;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

return /*hight in float*/;
}

// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

return [myArray count];

}

// Customize the appearance of table view cells.
- (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];
}

// Customize the Cell.
cell.selectionStyle = UITableViewCellSelectionStyleGray;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.textLabel.text = [myArray objectAtIndex: indexpath.row];
cell.textLabel.textAlignment = UITextAlignmentRight;
[cell.textLabel setFont:[UIFont fontWithName:@"Helvetica" size:18 ]];

return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

UIMyViewController* myViewController = [[UIMyViewController alloc] initWithNibName: @"MyView" bundle: nil];
[self.navigationController pushViewController: myViewController animated: YES];
[myViewController release];
}

No comments:

Post a Comment