Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在didselectrowatindexpath上推送新表视图?_Ios_Ios9_Xcode7 - Fatal编程技术网

Ios 如何在didselectrowatindexpath上推送新表视图?

Ios 如何在didselectrowatindexpath上推送新表视图?,ios,ios9,xcode7,Ios,Ios9,Xcode7,我不明白什么逻辑应该起作用 这是我的密码 I am new to iPhone Development. I am trying to push a new table view at didSelectRowAtIndexPath of previous table. 和其他表视图方法 - (void)viewDidLoad { [super viewDidLoad]; dentalDoc = [[NSMutableArray alloc]initWithObjects:@"one ",@

我不明白什么逻辑应该起作用

这是我的密码

I am new to iPhone Development. I am trying to push a new table view at didSelectRowAtIndexPath of previous table.
和其他表视图方法

- (void)viewDidLoad {
[super viewDidLoad];

dentalDoc = [[NSMutableArray alloc]initWithObjects:@"one ",@"two",@"Three", nil];
dentalDocImage = [[NSMutableArray alloc]initWithObjects:@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",nil];

searchDocList = [[NSMutableArray alloc]initWithObjects:@"Mary D'souza",@"Eric Josephson",@"Robert Adler",@"Lee Gold",@"Kevin Hansen",@"Karen Ziselman",@"Brad Gosky",@"Mark kogan",@"John Kong",@"Justin kohen",@"Oren Rehmanan",@"Paul Baker",@"Devashish Agarwal",@"Allen Chamberlin",@"Todd Lasner",@"Ryan walsh",@"steven Loan",@"Shrikant Mehta",@"Alexander lobo",nil];

doctorProfileImageList = [[NSMutableArray alloc]initWithObjects:@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",nil];}
searchIcons = [NSArray arrayWithObjects:@"empty-filter-xl",@"icon_place",@"ProfilePicRound",@"green_heart_rate",@"MYP",@"Maps-icon", nil];
searchNames = [NSArray arrayWithObjects:@"Dentist",@"MBBS",@"Psychiatrist",@"Cardiologist",@"Nurologist",@"Orthopedic",nil];
 dentalDoc = [[NSMutableArray alloc]initWithObjects:@"one ",@"two",@"Three", nil];
dentalDocImage = [[NSMutableArray alloc]initWithObjects:@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",nil];

mbbsDoc = [[NSMutableArray alloc]initWithObjects:@"MBBS 1",@"MBBS 2",@"MBBS 3",@"MBBS 4",@"MBBS 5",@"MBBS 6",@"MBBS 7", nil];
mbbsDocImage = [[NSMutableArray alloc]initWithObjects:@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon", nil];

PsychiatristDoc = [[NSMutableArray alloc]initWithObjects:@"Doctor 1",@"Doctroe 2",@"Doctor 3",@"Doctor 4",@"Doctor 5", nil];
PsychiatristDocImage = [[NSMutableArray alloc]initWithObjects:@"empty-filter-xl",@"icon_place",@"ProfilePicRound",@"green_heart_rate",@"MYP",nil];

searchDocList = [[NSMutableArray alloc]initWithObjects:@"Mary D'souza",@"Eric Josephson",@"Robert Adler",@"Lee Gold",@"Kevin Hansen",@"Karen Ziselman",@"Brad Gosky",@"Mark kogan",@"John Kong",@"Justin kohen",@"Oren Rehmanan",@"Paul Baker",@"Devashish Agarwal",@"Allen Chamberlin",@"Todd Lasner",@"Ryan walsh",@"steven Loan",@"Shrikant Mehta",@"Alexander lobo",nil];
doctorProfileImageList = [[NSMutableArray alloc]initWithObjects:@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",nil];
以及cellForRowAtIndexPath方法

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

// Return the number of sections.
return 1;}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
if (docsInt==0)
{
    return [dentalDoc count];
}
else
{
return [searchDocList count];
}}
我正在尝试检索医生列表,例如,牙医、MBBS、BHMS。 选择类别后,我想检索按类别选择的医生姓名列表表


请尽快回复。

如果您使用的是故事板,请使用以下代码

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

NSString *cellIdentifier  = @"cell";
SearchCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];

if(docsInt == 0)
{
    cell.lblDocName.text = [dentalDoc objectAtIndex:indexPath.row];
    cell.imgProfile.image = [UIImage imageNamed:[dentalDocImage objectAtIndex:indexPath.row]];

}
else
{
cell.lblDocName.text = [searchDocList objectAtIndex:indexPath.row];
cell.imgProfile.image = [UIImage imageNamed:[doctorProfileImageList objectAtIndex: indexPath.row]];

}
return cell;}
你也可以参考:


希望这是有用的

我已经找到了解决方法。 这是我的密码

I am new to iPhone Development. I am trying to push a new table view at didSelectRowAtIndexPath of previous table.
我有收藏视图。在menuViewController的视图加载方法中包含以下数组

DetailViewController* detailViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewControllerID"];

if([self.navigationController respondsToSelector:@selector(showViewController:sender:)])
    [self.navigationController showViewController:detailViewController sender:self];
else
    [self.navigationController pushViewController:detailViewController animated:animated];
这些是集合视图方法

- (void)viewDidLoad {
[super viewDidLoad];

dentalDoc = [[NSMutableArray alloc]initWithObjects:@"one ",@"two",@"Three", nil];
dentalDocImage = [[NSMutableArray alloc]initWithObjects:@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",nil];

searchDocList = [[NSMutableArray alloc]initWithObjects:@"Mary D'souza",@"Eric Josephson",@"Robert Adler",@"Lee Gold",@"Kevin Hansen",@"Karen Ziselman",@"Brad Gosky",@"Mark kogan",@"John Kong",@"Justin kohen",@"Oren Rehmanan",@"Paul Baker",@"Devashish Agarwal",@"Allen Chamberlin",@"Todd Lasner",@"Ryan walsh",@"steven Loan",@"Shrikant Mehta",@"Alexander lobo",nil];

doctorProfileImageList = [[NSMutableArray alloc]initWithObjects:@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",nil];}
searchIcons = [NSArray arrayWithObjects:@"empty-filter-xl",@"icon_place",@"ProfilePicRound",@"green_heart_rate",@"MYP",@"Maps-icon", nil];
searchNames = [NSArray arrayWithObjects:@"Dentist",@"MBBS",@"Psychiatrist",@"Cardiologist",@"Nurologist",@"Orthopedic",nil];
 dentalDoc = [[NSMutableArray alloc]initWithObjects:@"one ",@"two",@"Three", nil];
dentalDocImage = [[NSMutableArray alloc]initWithObjects:@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",nil];

mbbsDoc = [[NSMutableArray alloc]initWithObjects:@"MBBS 1",@"MBBS 2",@"MBBS 3",@"MBBS 4",@"MBBS 5",@"MBBS 6",@"MBBS 7", nil];
mbbsDocImage = [[NSMutableArray alloc]initWithObjects:@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon", nil];

PsychiatristDoc = [[NSMutableArray alloc]initWithObjects:@"Doctor 1",@"Doctroe 2",@"Doctor 3",@"Doctor 4",@"Doctor 5", nil];
PsychiatristDocImage = [[NSMutableArray alloc]initWithObjects:@"empty-filter-xl",@"icon_place",@"ProfilePicRound",@"green_heart_rate",@"MYP",nil];

searchDocList = [[NSMutableArray alloc]initWithObjects:@"Mary D'souza",@"Eric Josephson",@"Robert Adler",@"Lee Gold",@"Kevin Hansen",@"Karen Ziselman",@"Brad Gosky",@"Mark kogan",@"John Kong",@"Justin kohen",@"Oren Rehmanan",@"Paul Baker",@"Devashish Agarwal",@"Allen Chamberlin",@"Todd Lasner",@"Ryan walsh",@"steven Loan",@"Shrikant Mehta",@"Alexander lobo",nil];
doctorProfileImageList = [[NSMutableArray alloc]initWithObjects:@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",nil];
在didSelectItemAtIndexPath中,用户将推送到SearchList视图控制器,该控制器根据用户选择的医生类别显示一个表视图

以下是searchList视图控制器的代码

按医生类别列出的数组。视图中没有加载方法

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return searchIcons.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell";
FilterCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
cell.imgFilterIcon.image = [UIImage imageNamed:[searchIcons objectAtIndex:indexPath.row]];
cell.lblFilterCategory.text = [NSString stringWithFormat:@"%@",[searchNames objectAtIndex:indexPath.row]];

return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

SearchList *svc = [self.storyboard instantiateViewControllerWithIdentifier:@"storyBoardIdentifier"];
[self.navigationController pushViewController:svc animated:YES];

if ([[searchNames objectAtIndex:indexPath.row]isEqualToString:@"Dentist"])
{
    svc.docsInt = 0;

}
else if([[searchNames objectAtIndex:indexPath.row]isEqualToString:@"MBBS"])
{
    svc.docsInt = 1;
}
else if([[searchNames objectAtIndex:indexPath.row]isEqualToString:@"Psychiatrist"])
{
    svc.docsInt = 2;
}
else
{
    svc.docsInt = 3;
}
}
这是表视图方法

- (void)viewDidLoad {
[super viewDidLoad];

dentalDoc = [[NSMutableArray alloc]initWithObjects:@"one ",@"two",@"Three", nil];
dentalDocImage = [[NSMutableArray alloc]initWithObjects:@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",nil];

searchDocList = [[NSMutableArray alloc]initWithObjects:@"Mary D'souza",@"Eric Josephson",@"Robert Adler",@"Lee Gold",@"Kevin Hansen",@"Karen Ziselman",@"Brad Gosky",@"Mark kogan",@"John Kong",@"Justin kohen",@"Oren Rehmanan",@"Paul Baker",@"Devashish Agarwal",@"Allen Chamberlin",@"Todd Lasner",@"Ryan walsh",@"steven Loan",@"Shrikant Mehta",@"Alexander lobo",nil];

doctorProfileImageList = [[NSMutableArray alloc]initWithObjects:@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",nil];}
searchIcons = [NSArray arrayWithObjects:@"empty-filter-xl",@"icon_place",@"ProfilePicRound",@"green_heart_rate",@"MYP",@"Maps-icon", nil];
searchNames = [NSArray arrayWithObjects:@"Dentist",@"MBBS",@"Psychiatrist",@"Cardiologist",@"Nurologist",@"Orthopedic",nil];
 dentalDoc = [[NSMutableArray alloc]initWithObjects:@"one ",@"two",@"Three", nil];
dentalDocImage = [[NSMutableArray alloc]initWithObjects:@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",nil];

mbbsDoc = [[NSMutableArray alloc]initWithObjects:@"MBBS 1",@"MBBS 2",@"MBBS 3",@"MBBS 4",@"MBBS 5",@"MBBS 6",@"MBBS 7", nil];
mbbsDocImage = [[NSMutableArray alloc]initWithObjects:@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon", nil];

PsychiatristDoc = [[NSMutableArray alloc]initWithObjects:@"Doctor 1",@"Doctroe 2",@"Doctor 3",@"Doctor 4",@"Doctor 5", nil];
PsychiatristDocImage = [[NSMutableArray alloc]initWithObjects:@"empty-filter-xl",@"icon_place",@"ProfilePicRound",@"green_heart_rate",@"MYP",nil];

searchDocList = [[NSMutableArray alloc]initWithObjects:@"Mary D'souza",@"Eric Josephson",@"Robert Adler",@"Lee Gold",@"Kevin Hansen",@"Karen Ziselman",@"Brad Gosky",@"Mark kogan",@"John Kong",@"Justin kohen",@"Oren Rehmanan",@"Paul Baker",@"Devashish Agarwal",@"Allen Chamberlin",@"Todd Lasner",@"Ryan walsh",@"steven Loan",@"Shrikant Mehta",@"Alexander lobo",nil];
doctorProfileImageList = [[NSMutableArray alloc]initWithObjects:@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",@"ProfilePicRound",@"MapiCon",nil];
最后但并非最不重要的是导航方法

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
if (docsInt==0)
{
    return [dentalDoc count];
}
if (docsInt==1)
{
    return [mbbsDoc count];
}


 if (docsInt == 2){
   return [PsychiatristDoc count];}
else
{
    (docsInt == 3);
    return [searchDocList count];
}}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

NSString *cellIdentifier  = @"cell";
SearchCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];

if(docsInt == 0)
{
    cell.lblDocName.text = [dentalDoc objectAtIndex:indexPath.row];
    cell.imgProfile.image = [UIImage imageNamed:[dentalDocImage objectAtIndex:indexPath.row]];
}
else if (docsInt == 1)
{
    cell.lblDocName.text = [mbbsDoc objectAtIndex:indexPath.row];
    cell.imgProfile.image = [UIImage imageNamed:[mbbsDocImage objectAtIndex:indexPath.row]];
}
else if(docsInt == 2)
{
    cell.lblDocName.text = [PsychiatristDoc objectAtIndex:indexPath.row];
    cell.imgProfile.image = [UIImage imageNamed:[PsychiatristDocImage objectAtIndex:indexPath.row]];
}
else
{

    cell.lblDocName.text = [searchDocList objectAtIndex:indexPath.row];
    cell.imgProfile.image = [UIImage imageNamed:[doctorProfileImageList objectAtIndex: indexPath.row]];
}
    return cell;}

谢谢。

是否使用故事板?为tableview设置标记,只需更改didselectRow上的标记,然后重新加载我正在使用故事板的表格。我只想在一个视图控制器中检索表格视图格式。例如,如果我选择了“牙医”。以表格视图格式显示给searchListController的数据的3。当我选择MBBS时。然后,searchListController将检索与MBBS doctor相关的医生列表。pushViewController成功运行。searchListController也会出现。但它只显示与牙医相关的数据。不是其他类别的数据。你可以分享你的项目在邮政编码和邮件给我,我会检查我已经找到了解决方案,请检查下面。