I hav a UITableViewCell
and UITableView
in a single view.Clicking on particular row of UITableView
,It navigates to anotherViewController.But I am not able to navigate to otherViewController on clicking UITableViewCell
.How can i do this??
For UITableView
I am using this code:
-(void)pushView1:(id)sender{
if(edController == nil)
edController = [[EditableDetailCell alloc] initWithNibName:@"EditableDetailCell" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:edController animated:YES];
}
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UITableViewCell *tbcel;
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
tbcel.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
tbcel.layer.cornerRadius = 15;
tbcel.text = aBook.Name;
switch(indexPath.section)
{
case 0:
cell.text = aBook.Address;
break;
case 1:
cell.text = aBook.Phone;
break;
case 2:
cell.text = aBook.Purchase;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(edController == nil)
edController = [[EditableDetailCell alloc] initWithNibName:@"EditableDetailCell" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:edController animated:YES];
}
What should I do for UITableViewCell??
Edit:
what you want to push is not a UITableViewCell
It's another View.
You can say
YourCustomView *view = [[YourCustomView alloc] init];
[self.navigationController pushViewController:view animated:Yes];
but I never see any code passing to another cell.
A cell is used to customize the look of you UITableView.
Add:
I think the if statement is not useful here.
Do you mean
if(edController == nil){
edController = [[EditableDetailCell alloc] initWithnibName:@"EditableDetailCell" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:edController animated:YES];
}
or an empty view is going to be passed any way.
(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(“Selected Row %d”, indexPath.row);
YourNextViewController *objVC = (YourNextViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ViewControllerIdentifier"];
[self presentViewController: objVC animated:YES completion:nil];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With