从 didselectrowatindexpath 加载多个详细视图
我有一个表视图,基本上只有 2 行,添加类别和删除类别。在选择添加类别时,我想加载添加类别视图,对于删除类别也类似。我该怎么做呢,因为 if 语句没有帮助。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *selectedCategory = [functionName objectAtIndex:[indexPath row]];
KeyCryptAppAppDelegate *appDelegate = (KeyCryptAppAppDelegate *)[[UIApplication sharedApplication] delegate];
if (selectedCategory = @"Add Category")
{
addCategoryView = [[AddCategoryView alloc]initWithNibName:@"AddCategoryView" bundle:nil];
[appDelegate.categoryNavController pushViewController:addCategoryView animated:YES];
}
if (selectedCategory = @"Delete Category")
{
deleteCategoryView = [[DeleteCategoryView alloc]initWithNibName:@"DeleteCategoryView" bundle:nil];
[appDelegate.categoryNavController pushViewController:deleteCategoryView animated:YES];
}}
此代码将使添加类别视图出现在两个详细视图中,而不是右侧的视图中。 请指教!
谢谢!
[编辑]
大家好,感谢您在相对较短的时间内提供的所有答案!真的很感激。
I have a table view, with just basically 2 rows, add category and delete category. On selection of lets say add category i want to load an add category view, and similar for the delete category. How would i go about doing this, cos an if statement doesn't help.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *selectedCategory = [functionName objectAtIndex:[indexPath row]];
KeyCryptAppAppDelegate *appDelegate = (KeyCryptAppAppDelegate *)[[UIApplication sharedApplication] delegate];
if (selectedCategory = @"Add Category")
{
addCategoryView = [[AddCategoryView alloc]initWithNibName:@"AddCategoryView" bundle:nil];
[appDelegate.categoryNavController pushViewController:addCategoryView animated:YES];
}
if (selectedCategory = @"Delete Category")
{
deleteCategoryView = [[DeleteCategoryView alloc]initWithNibName:@"DeleteCategoryView" bundle:nil];
[appDelegate.categoryNavController pushViewController:deleteCategoryView animated:YES];
}}
This code would make add category view appear in both detail views instead of the right one.
Please advise!
Thanks!
[EDIT]
Hey guys thanks for all your answers in a relatively short amount of time! Really appreciate it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将此代码更改为
You need to change this code to
你的比较方式是错误的。
一切顺利。
Your way of comparison is wrong .
All the best.