Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.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 如何从一个视图控制器导航到另一个视图控制器?_Iphone_Ios_Xcode - Fatal编程技术网

Iphone 如何从一个视图控制器导航到另一个视图控制器?

Iphone 如何从一个视图控制器导航到另一个视图控制器?,iphone,ios,xcode,Iphone,Ios,Xcode,我有两个视图控制器,在第一个视图控制器中我有一个按钮,现在我想让用户点击该按钮,然后他们将转到第二个视图控制器。我没有使用故事板,确实使用了ARC,我已经尝试过了,但它显示了错误“uiviewcontroller没有可见的@interface声明选择器alloc” 您正在将“*MessageViewController”声明为UIViewController类型。然后调用“MessageViewController”alloc方法。你不能那样做。Maulik在正确的轨道上,但如果使用ARC,则需

我有两个视图控制器,在第一个视图控制器中我有一个按钮,现在我想让用户点击该按钮,然后他们将转到第二个视图控制器。我没有使用故事板,确实使用了ARC,我已经尝试过了,但它显示了错误“uiviewcontroller没有可见的@interface声明选择器alloc”

您正在将“*MessageViewController”声明为UIViewController类型。然后调用“MessageViewController”alloc方法。你不能那样做。Maulik在正确的轨道上,但如果使用ARC,则需要删除最后一行([aMessageViewController release];)

尝试:

不要忘记,您需要一种方法来关闭模态视图控制器,您可以通过在上面最后一行之前添加类似的内容来设置表示和转换样式:

myMessageViewControllerInstance.modalPresentationStyle = UIModalPresentationFormSheet;
myMessageViewControllerInstance.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
还有其他风格,我只是举了一些例子。祝您好运

您将“*MessageViewController”声明为UIViewController类型。然后调用“MessageViewController”alloc方法。你不能那样做。Maulik在正确的轨道上,但如果使用ARC,则需要删除最后一行([aMessageViewController release];)

    - (IBAction)SendMsg:(id)sender {

MessageViewController *aMessageViewController = [[MessageViewController alloc] initWithNibName:@"MessageViewController" bundle:nil];
[self presentModalViewController:aMessageViewController animated:YES];
[aMessageViewController release];

}
尝试:

不要忘记,您需要一种方法来关闭模态视图控制器,您可以通过在上面最后一行之前添加类似的内容来设置表示和转换样式:

myMessageViewControllerInstance.modalPresentationStyle = UIModalPresentationFormSheet;
myMessageViewControllerInstance.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
还有其他风格,我只是举了一些例子。祝你好运

    - (IBAction)SendMsg:(id)sender {

MessageViewController *aMessageViewController = [[MessageViewController alloc] initWithNibName:@"MessageViewController" bundle:nil];
[self presentModalViewController:aMessageViewController animated:YES];
[aMessageViewController release];

}
如果您使用的是导航控制器,那么您也可以使用self.navigationController


如果使用了导航控制器,则可以使用self.navigationController……。另外。

MessageViewController*aMessageViewController=[[MessageViewController alloc]initWithNibName:@“MessageViewController”捆绑包:nil]@chetan,不一样,仔细检查,并阅读我之前对MessageViewController*aMessageViewController=[[MessageViewController alloc]initWithNibName:@“MessageViewController”bundle:nil]的评论@chetan,不一样,仔细检查,并阅读我之前的评论,它在哪一行显示错误?在哪一行显示错误?…presentModalViewController:。。。不推荐用于iOS 6。改用[self-presentViewController:obj动画:是完成:无];。。。presentModalViewController:。。。不推荐用于iOS 6。改用[self-presentViewController:obj动画:是完成:无];
myMessageViewControllerInstance.modalPresentationStyle = UIModalPresentationFormSheet;
myMessageViewControllerInstance.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    - (IBAction)SendMsg:(id)sender {

MessageViewController *aMessageViewController = [[MessageViewController alloc] initWithNibName:@"MessageViewController" bundle:nil];
[self presentModalViewController:aMessageViewController animated:YES];
[aMessageViewController release];

}