开发者

Loading more than one detail view from didselectrowatindexpath

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 didSelectRowAtIndex开发者_开发知识库Path:(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.


You need to change this code to

if ([selectedCategory isEqualTo:@"Add Category"])
{

    addCategoryView = [[AddCategoryView alloc]initWithNibName:@"AddCategoryView" bundle:nil]; 
    [appDelegate.categoryNavController pushViewController:addCategoryView animated:YES];

}
else if([selectedCategory isEqualTo:@"Delete Category"])
{
    deleteCategoryView = [[DeleteCategoryView alloc]initWithNibName:@"DeleteCategoryView" bundle:nil]; 
    [appDelegate.categoryNavController pushViewController:deleteCategoryView animated:YES]; 
}}


Your way of comparison is wrong .

if ([selectedCategory isEqualToString:@"Add Category"])

All the best.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜