我是Xcode中的新手,现在我正在开发一个可扩展/可折叠的UITableView。基本思想是在单击第一个主单元格并且子单元格可以切换到详细视图时创建新的子下拉单元格。但我希望从这些新的子细胞中获得详细信息。我发现有两种选择:
我拖动了一个新的视图控制器并定义了它的故事板ID,并尝试以编程方式创建一个segue来推送新的详细信息视图。但它不起作用。谁能帮助我?感谢。
// didSelectRowAtIndexPath方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//to change the button image when selecting a row.
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UIButton *arrowBtn = (UIButton*)[cell viewWithTag:10];
NSDictionary *dic=[self.itemsinTable objectAtIndex:indexPath.row];
if([dic valueForKey:@"list"])
{
NSArray *listarray=[dic valueForKey:@"list"];
BOOL isTableExpanded=NO;
for(NSDictionary *subitems in listarray )
{
NSInteger index=[self.itemsinTable indexOfObjectIdenticalTo:subitems];
isTableExpanded=(index>0 && index!=NSIntegerMax);
if(isTableExpanded) break;
}
if(isTableExpanded)
{
[self CollapseRows:listarray];
[arrowBtn setImage:[UIImage imageNamed:@"down_arrow.png"] forState:UIControlStateNormal];
}
else
{
NSUInteger count=indexPath.row+1;
NSMutableArray *arrCells=[NSMutableArray array];
for(NSDictionary *dInner in listarray )
{
[arrCells addObject:[NSIndexPath indexPathForRow:count inSection:0]];
[self.itemsinTable insertObject:dInner atIndex:count++];
}
[self.expandingtableView insertRowsAtIndexPaths:arrCells withRowAnimation:UITableViewRowAnimationTop];
[arrowBtn setImage:[UIImage imageNamed:@"up_arrow.png"] forState:UIControlStateNormal];
//This segue is not working...
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"detailvcontroller"];
[self.navigationController pushViewController:controller animated:YES];}}}
答案 0 :(得分:1)
void Update () {
transform.rotation = Quaternion.Euler(0f, Input.mousePosition.x, Input.mousePosition.y);
}
答案 1 :(得分:0)
你需要在这里检查几件事情:
DetailViewController
的故事板标识符设置正确。self.storyboard
已正确初始化。 我刚刚添加了以下故事板初始化代码。请确保以这种方式设置self.storyboard
:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
DetailViewController *viewController = (DetailViewController *)[storyboard instantiateViewControllerWithIdentifier:@"detailvcontroller"];
[self.navigationController pushViewController:controller animated:YES];