Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.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
Iphone 通过使用xcode 4.2和情节提要的代码更改视图?_Iphone_Objective C_Ios_Ipad - Fatal编程技术网

Iphone 通过使用xcode 4.2和情节提要的代码更改视图?

Iphone 通过使用xcode 4.2和情节提要的代码更改视图?,iphone,objective-c,ios,ipad,Iphone,Objective C,Ios,Ipad,如何使用xcode 4.2和情节提要通过代码更改视图? 我试图在单击动态表视图单元格后更改视图。 因为它是动态的,我不能把它和一个序列联系起来 我已经尝试过按照另一篇关于堆栈溢出的文章的建议使用此代码进行更改,但它不起作用: UIViewController *alertView = [self.storyboard instantiateViewControllerWithIdentifier:@"alertView"]; [self.navigationController pushVie

如何使用xcode 4.2和情节提要通过代码更改视图? 我试图在单击动态表视图单元格后更改视图。
因为它是动态的,我不能把它和一个序列联系起来

我已经尝试过按照另一篇关于堆栈溢出的文章的建议使用此代码进行更改,但它不起作用:

 UIViewController *alertView = [self.storyboard instantiateViewControllerWithIdentifier:@"alertView"];
[self.navigationController pushViewController:alertView animated:YES];
这是我的一段代码,希望能有所帮助

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row==0){
     UIViewController *alertView = [self.storyboard instantiateViewControllerWithIdentifier:@"alertView"];
[self.navigationController pushViewController:alertView animated:YES];
    NSLog(@"This code is being called...");
}

这是一个更好的故事板教程,它碰巧使用了TableView


在故事板中创建一个从
UITableViewController
alertView
的序列。确保通过将控件从控制器(第一响应者图标旁边)拖动到
alertView
来执行此操作,而不是从表格单元格拖动或类似操作。选择“推送”的序列类型。单击segue的属性并确保为其提供一个标识符,如
AlertViewSegue

现在,您可以通过以下代码以编程方式调用segue:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.row==0){
        [self performSegueWithIdentifier:@"AlertViewSegue" sender:self];
    }
}

如果我不清楚,我想知道当用户单击动态表视图单元格时如何切换视图。我已经知道如何使用数组创建动态表视图。我浏览了教程并下载了源代码,但仍然没有清除任何内容,因为当您单击这些动态单元格时,什么也没有发生。“因为它是动态的,我不能将其与segue链接…”呃,是的,您可以-只需按ctrl键从原型拖动到下一个视图控制器。你有没有试过这个,但运气不好?