UITableViewCell和UITableView(选择一行)导航到otherViewcontroller [英] UITableViewCell and UITableView (did select a row) navigation to otherViewcontroller
问题描述
我在一个视图中有一个 UITableViewCell
和 UITableView
.单击 UITableView
的特定行,它导航到另一个ViewController.但是我是单击 UITableViewCell
时无法导航到otherViewController.我该怎么做?
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??
对于 UITableView
,我正在使用以下代码:
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];
}
我应该如何处理UITableViewCell?
What should I do for UITableViewCell??
推荐答案
您要推送的不是UITableViewCell
what you want to push is not a UITableViewCell
这是另一个视图.
你可以说
YourCustomView *view = [[YourCustomView alloc] init];
[self.navigationController pushViewController:view animated:Yes];
但是我从来没有看到任何代码传递到另一个单元格.
but I never see any code passing to another cell.
单元格用于自定义UITableView的外观.
A cell is used to customize the look of you UITableView.
添加:
我认为if语句在这里没有用.
I think the if statement is not useful here.
你是说
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.
这篇关于UITableViewCell和UITableView(选择一行)导航到otherViewcontroller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!