Ios 我的IBAction在单击时不工作
我在mainViewController中创建一个按钮。该按钮应转到页面ItaliaViewController,但我的按钮不工作 这是我的密码Ios 我的IBAction在单击时不工作,ios,ibaction,Ios,Ibaction,我在mainViewController中创建一个按钮。该按钮应转到页面ItaliaViewController,但我的按钮不工作 这是我的密码 -(IBAction)openRubric:(id)sender { ItaliaViewController *italia = [self.storyboard instantiateViewControllerWithIdentifier:@"rubric_italia"]; } 请帮助我首先在按钮操作中放置
-(IBAction)openRubric:(id)sender
{
ItaliaViewController *italia = [self.storyboard instantiateViewControllerWithIdentifier:@"rubric_italia"];
}
请帮助我首先在按钮操作中放置一个NSLog。如果它在按钮操作上打印了一些内容,则表示您的按钮工作正常,并且在导航视图控制器时出错。如果没有,请检查XIB中的按钮连接
NSLog(@"button action is working);
您必须展示新的视图控制器,例如z ItaliaViewController。 用这个
[self presentViewController:italia animated:YES completion:nil];
首先,您的代码并不意味着将显示新的视图控制器,因为您必须调用
presentViewController
函数来调用新的控制器,但首先需要检查该函数是否被调用。这样说吧
[self presentViewController:italia animated:YES completion:nil]
在按钮代码中写入NSLog
,或者放置调试点以测试函数是否被调用。如果未调用该函数,请确保已将该函数连接到情节提要中的按钮
UIStoryboard *newStoryboard = [UIStoryboard storyboardWithName:@"ViewName" bundle:nil];
ViewName *firstvc = [newStoryboard instantiateInitialViewController];
[self presentViewController:firstvc animated:YES completion:nil];
不要忘记将Stroyboard视图的头文件导入到要从中打开它的视图的头文件或实现文件中。如上所述,您必须执行一些步骤来解决此问题 1-检查UIButton是否通过
插座连接
,动作事件在里面
2-通过导航或如上所述使用self-presentViewController`,将视图推入堆栈
希望这能解决您的问题。谢谢您的帮助。它起作用了 这是我的密码:
-(IBAction)openRubric:(id)sender
{
self.slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Italia"];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
你能告诉我们如何将按钮的iAction与你的按钮Outlate连接吗?通过storyboradcheck上的connections inspector,它与TouchUpInsed连接,或者什么…?你只是在实例化一个VC,但却没有展示它。你还期望什么?是的,我和TouchUpInsed连接