ECSlidingViewController如何使用iOS中的动画从一个TopViewController移动到另一个TopViewController
我在我的应用程序中使用ECSlidingViewController进行Facebook样式滑动效果。我有2个TopViewController,一个左侧和一个右侧视图控制器和一个是slidingviewcontroller子类的initviewcontroller。ECSlidingViewController如何使用iOS中的动画从一个TopViewController移动到另一个TopViewController
1. InitViewController:ECSlidingViewController
2.MainViewController(TopViewController)
3.LeftMenuViewContrller(UIViewController中)
4.RightMenuViewController(UIViewController中)
5.DetailViewController(TopViewController)
我有我的MainViewController包含日历事件的tableview。问题是我想通过单击tableView:didSelectRowAtIndexPath:中的事件来显示事件详细信息,这是带有一些动画(我目前无法获得)的另一个topview控制器的事件,从而将MainViewController转到DetailViewController。我使用下面的代码,就是让我的DetailViewController
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DetailsViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"details"];
self.slidingViewController.topViewController = newTopViewController;
[self.slidingViewController resetTopView];
}
这是我viewDidLoad方法
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.layer.shadowOpacity = 0.75f;
self.view.layer.shadowRadius = 10.0f;
self.view.layer.shadowColor = [UIColor blackColor].CGColor;
if (![self.slidingViewController.underLeftViewController isKindOfClass:[LeftViewController class]]) {
self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Left"];
}
if (![self.slidingViewController.underRightViewController isKindOfClass:[RightViewController class]]) {
self.slidingViewController.underRightViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Right"];
}
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
}
我想获得像的UINavigationController或莫代尔风格
[self.navigationController pushViewController:newTopViewController animated:YES];
动画或
[self presentViewController:newTopViewController animated:YES completion:nil];
请帮忙。谢谢。
你在使用故事板吗?你能否执行Segue?在故事板中,将名称,链接和样式设置为Modal以及Transition。
在你DidSelectRowAtIndex把这个
[self performSegueWithIdentifier:@"eventDetail" sender:@(indexPath.row)];
然后宣布这个方法
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"eventDetail"])
{
DetailsViewController *destViewController = segue.destinationViewController;
destViewController.eventRow = sender;
}
// You can test for other Segue names here
}
然后在DetailsViewController.h把
// Allows sending View Controller to give this controller data
@property (nonatomic, strong) int *eventRow;
而在.M把
@synthesize eventRow;
现在在您的DetailsViewController中,它应该动画并禁用滑动(除非您正常声明所有ECS位)。你也有一个Int eventRow它告诉你哪个单元被点击。
您可以创建一个后退按钮并执行此操作;
[self dismissViewControllerAnimated:YES completion:nil];
编辑
或者你可以尝试这个,但我不知道是否会加上动画效果,你需要弄清楚如何传递的东西,也许是两者的结合...
UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"eventDetail"];
CGRect frame = self.slidingViewController.topViewController.view.frame;
self.slidingViewController.topViewController = newTopViewController;
self.slidingViewController.topViewController.view.frame = frame;
[self.slidingViewController resetTopView];
Justed编辑,意味着DidSelect不是CellAt。 –
感谢您的回复。是的,我正在使用故事板。我尝试了这个选项,但是因为我使用ecslidingviewcontroller进行导航和滑动,所以您提到的方法仅适用于第一次启动应用程序并单击行时。我有不同的视图控制器的细节和MainViewController,它显示我的应用程序的菜单。 – suhit
我已经完成了一个使用ECSlidding的应用程序,并且我有很多集合视图和表格可以推送到其他视图。我以为我用过这种方法,但也许这是其他的东西搞砸了。我会找到代码和检查... –
我遇到了同样的挑战,并使用segue的。但是失去了我想要的Push动画。有任何更新有这个想法? –