Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.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
Objective c 如何从xib迁移到xib_Objective C - Fatal编程技术网

Objective c 如何从xib迁移到xib

Objective c 如何从xib迁移到xib,objective-c,Objective C,从一页移动到另一页最好的代码是什么?我有一个4页的问卷,我从4个XIB加载了4个视图 在我的案例中,我选择了两种从xib到xib的方式,从一页到另一页。 方法1: -(IBAction) MaleTapped: (id) sender { Page1M *ivc = [[Page1M alloc] init]; UINavigationController *nc = [[UINavigationController alloc]

从一页移动到另一页最好的代码是什么?我有一个4页的问卷,我从4个XIB加载了4个视图

在我的案例中,我选择了两种从xib到xib的方式,从一页到另一页。 方法1:

-(IBAction) MaleTapped: (id) sender {
    Page1M *ivc = [[Page1M alloc] init];
    UINavigationController *nc = [[UINavigationController alloc]
                                  initWithRootViewController:ivc];
    [self presentModalViewController:nc animated:NO];
    [ivc release];
    [nc release];
}
第二种方式:

-(IBAction)GotoPage2M:(id)sender {
    page2M = [ [Page2M alloc]
              initWithNibName:@"Page2M" bundle:nil];
    [self.view addSubview:page2M.view];}
一种方法使用RootViewController方法,第二种方法仅加载子视图。对于我的4个页面,哪种方式更好/更干净/更智能?

我建议以这种方式使用UINavigationViewController。深入到几个模态视图是令人讨厌的

- (IBAction) goToNextPage:(id)sender {
    UIViewController * newView = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
    [self.navigationController pushViewController:newView animated:YES];
    [newView release];
}

我选择子视图的唯一原因是为了额外的转换选项。

我建议查看Apple的示例代码。它展示了如何通过多个视图控制器创建页面,并从XIB动态加载它们。该示例只是多次加载同一个xib,但您可以将其替换为为为每个页面加载不同视图控制器或xib的代码。

Cory,这不起作用,前两个都起作用,但由于某种原因,这一个不起作用。下一个nib与委托人有很大关系,比如。。。。。。无法告诉你原因,但这不起作用。。。。当我按下IBAcation按钮时,它构建得很好,没有错误消息,但它不工作。我知道我不想要子视图或模态视图。但通常的方法对我不起作用。还有其他建议吗?山姆,我喜欢,但现在。。。。我很喜欢,谢谢。。。。。。但现在,我只需要翻开一些视图/页面,完成概念验证应用程序……答案中的链接已经过期,可能是我的本意。