Sunday, June 27, 2010

Picker View Methods

#pragma mark -
#pragma mark UIPickerViewDelegate methods

- (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
NSString *str = [myArray objectAtIndex:row];
return str;
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
UIMyViewController *myViewController = [[UIMyViewController alloc] initWithNibName:@"MyView" bundle:nil];
[self.navigationController pushViewController:myViewController animated:YES];
[myViewController release];
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return /*no of Components (Partitions of Picker)*/;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [myArray count];
}

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];
}