Iphone removeFromSuperView…如何从每个controllerview中删除所有组件?
我有一个关于UITableView、堆栈和移除组件或可能在堆栈上隐藏组件的问题。 首先,我有一个添加组件(按钮)的功能 我在我的字典中调用这个函数 didSelectRowAtindexPath 到目前为止,一切顺利 现在是“有趣”部分。Iphone removeFromSuperView…如何从每个controllerview中删除所有组件?,iphone,objective-c,uitableview,Iphone,Objective C,Uitableview,我有一个关于UITableView、堆栈和移除组件或可能在堆栈上隐藏组件的问题。 首先,我有一个添加组件(按钮)的功能 我在我的字典中调用这个函数 didSelectRowAtindexPath 到目前为止,一切顺利 现在是“有趣”部分。 我有另一个功能是附加到一个巴布托 这会在堆栈上推送下一个控制器 -(void)lastView:(id)sender { selectedRow = [self.tableView indexPathForSelectedRow]; NSUInteger
我有另一个功能是附加到一个巴布托 这会在堆栈上推送下一个控制器
-(void)lastView:(id)sender
{
selectedRow = [self.tableView indexPathForSelectedRow];
NSUInteger row = selectedRow.row;
NSUInteger section = selectedRow.section;
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:section] animated:YES scrollPosition:UITableViewScrollPositionBottom];
[self tableView:[self tableView] didSelectRowAtIndexPath:selectedRow];
NSDictionary *dictionary = [self.tableDataSource objectAtIndex:selectedRow.row];
//Get the children of the present item.
NSArray *Children = [dictionary objectForKey:@"Children"];
rvController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]];
//Increment the Current View
rvController.CurrentLevel += 1;
//Push the new table view on the stack
[self.navigationController pushViewController:rvController animated:NO];
rvController.tableDataSource = Children;
[rvController release];
}
}
我希望从屏幕上删除playButton,但不幸的是,removeFromSuperView不起作用。我猜这与在堆栈上按下一个新的rvController有关,因为当我这样做时,它确实完美地移除了我的按钮
是否有人知道我如何确保按钮从堆栈上的所有视图中移除,而不仅仅是看起来的“当前”视图
编辑:
这是另一个“有趣”的部分
如果我在这里输入一些伪代码(但它会推送另一个viewcontroller)
像这样:
-(void)lastView:(UITableview *)tableView selectingRow:(NSIndexPath *)indexPath
{
NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];
//Get the children of the present item.
NSArray *Children = [dictionary objectForKey:@"Children"];
rvController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]];
//Increment the Current View
rvController.CurrentLevel += 1;
//Push the new table view on the stack
[self.navigationController pushViewController:rvController animated:NO];
rvController.tableDataSource = Children;
[rvController release];
}
}
然后它似乎起作用了。虽然我不是很确定,但它确实“看起来”像在工作 好的,很有趣。。当我这样写函数的时候。。一切都很好
selectedRow = [self.tableView indexPathForSelectedRow];
NSDictionary *dictionary = [self.tableDataSource objectAtIndex:selectedRow.row];
//Get the children of the present item.
NSArray *Children = [dictionary objectForKey:@"Children"];
rvController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]];
//Increment the Current View
rvController.CurrentLevel += 1;
//Set the title;
rvController.CurrentTitle = [dictionary objectForKey:@"Title"];
//Push the new table view on the stack
[self.navigationController pushViewController:rvController animated:YES];
rvController.tableDataSource = Children;
[rvController release];
嗯,但是我仍然不完全满意,但是现在就必须这样做 您有多少个按钮实例?
selectedRow = [self.tableView indexPathForSelectedRow];
NSDictionary *dictionary = [self.tableDataSource objectAtIndex:selectedRow.row];
//Get the children of the present item.
NSArray *Children = [dictionary objectForKey:@"Children"];
rvController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]];
//Increment the Current View
rvController.CurrentLevel += 1;
//Set the title;
rvController.CurrentTitle = [dictionary objectForKey:@"Title"];
//Push the new table view on the stack
[self.navigationController pushViewController:rvController animated:YES];
rvController.tableDataSource = Children;
[rvController release];