[英]Animating another viewcontroller storyboard scene programatically
I am working through a tutorial that is demonstrating a facebook/path left hand nav 我正在完成一个教程,该教程演示了Facebook / path左侧导航
http://hsapkota.com.au/index.php/blog/ios-iphone-ipad/28-tutorial-creating-gmail-facebook-like-menu-navigation-in-ios http://hsapkota.com.au/index.php/blog/ios-iphone-ipad/28-tutorial-creating-gmail-facebook-like-menu-navigation-in-ios
Everything is working as expected, however I wanted to add a close navigation button in the navigation table, but I can't seem to fire the same method or access the storyboard scene from the navigation class 一切都按预期工作,但是我想在导航表中添加一个关闭的导航按钮,但似乎无法触发相同的方法或无法从导航类访问情节提要场景
this is an example of one way I was trying to perform the task 这是我尝试执行任务的一种方式的示例
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSString * storyboardName = @"MainStoryboard_iPhone";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UINavigationController * vc = [storyboard instantiateViewControllerWithIdentifier:@"main"];
[UIView animateWithDuration:0.2f
delay:0.0
options:UIViewAnimationCurveLinear
animations:^{
CGAffineTransform trans = CGAffineTransformMakeTranslation(200.0, 0.0);
vc.view.transform= trans;
}
completion:^(BOOL finished){
}
];
}
'main' is the storyboardID I that is I would like to animate, however on performing an NSLog on 'vc.navigationController' I get a NULL return - although logging 'vc' returns the class name associated with the correct storyboard scene 'main'是我要设置动画的StoryboardID,但是在'vc.navigationController'上执行NSLog时,我会返回NULL-尽管登录'vc'会返回与正确的Storyboard场景关联的类名
Any help would be appreciated I just can't get my head around it! 任何帮助将不胜感激,我只是无法解决!
-edit I thought I was able to edit the 'main view' calling superview in my transform self.view.superview.transform= trans -edit我以为我可以在转换self.view.superview.transform = trans中编辑调用superview的“主视图”
however this animates both viewcontrollers and also renders 'main view' useless as non of the tap gestures respond in this view now... 但是,这既使视图控制器动画化,又使“主视图”无用,因为现在没有轻击手势在该视图中做出响应...
Any further thoughts? 还有其他想法吗?
Okay after a lot of faffing about I managed to get something to work 好多事后,我设法工作了
I needed to contact the appdelegate in order to access the other viewcontroller in context 我需要联系appdelegate以便在上下文中访问其他viewcontroller
my code is now 我的代码是现在
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
AppDelegate* appDel = (AppDelegate*)[[UIApplication sharedApplication] delegate];
MainView *mv = (MainView *)appDelegate.window.rootViewController;
[UIView animateWithDuration:0.2f
delay:0.0
options:UIViewAnimationCurveLinear
animations:^{
CGAffineTransform trans = CGAffineTransformMakeTranslation(-0.0, 0.0);
mv.view.transform= trans;
}
completion:^(BOOL finished){
}
];
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.