0

I am using ECSlidingViewController in my app for Facebook style swipe effect. I have 2 TopViewControllers, one left and one right side view controller and one initviewcontroller which is a slidingviewcontroller subclass.

1. InitViewController:ECSlidingViewController

2.MainViewController (TopViewController)

3.LeftMenuViewContrller (UIViewController)

4.RightMenuViewController (UIViewController)

5.DetailViewController (TopViewController)

I have tableview on my MainViewController which contains the calendar events. The problem is that I want to go to MainViewController to DetailViewController by clicking the event in tableView:didSelectRowAtIndexPath: methods to show the events details which is another topview controller with some animation( which I am unable to get so far). I am using following code which is getting me to the DetailViewController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {   
 DetailsViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"details"];
    self.slidingViewController.topViewController = newTopViewController;
    [self.slidingViewController resetTopView];
}

this is my viewDidLoad method

 - (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];
    
}

I want to get the animation like the UINavigationController or Modal style

[self.navigationController pushViewController:newTopViewController animated:YES];

or

[self presentViewController:newTopViewController animated:YES completion:nil];

please help. thank you.

Community
  • 1
  • 1
Suhit Patil
  • 11,748
  • 3
  • 50
  • 60
  • I'm experiencing the same challenge, and using segue's. But lose the Push animation that I want. Any update to having this figured out? – Sebastian Dwornik Jan 16 '14 at 15:00

1 Answers1

0

Are you using Storyboard? Could you perform a Segue? In the storyboard setup the name and the link and style as Modal along with the Transition.

In your DidSelectRowAtIndex put this

[self performSegueWithIdentifier:@"eventDetail" sender:@(indexPath.row)];

Then declare this method

-(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
}

Then in the DetailsViewController.h put

// Allows sending View Controller to give this controller data
@property (nonatomic, strong) int *eventRow;

And in the .m put

@synthesize eventRow;

Now in your DetailsViewController it should animate to it and the sliding will be disabled (unless you declare all the ECS bits as normal). You also have an Int eventRow which tells you which cell was clicked.

You can create a back button and do this;

[self dismissViewControllerAnimated:YES completion:nil];

EDIT

OR you could try this but I am not sure if it will animate plus you need to figure out how to pass stuff, maybe a combination of the two...

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];
Recycled Steel
  • 2,272
  • 3
  • 30
  • 35
  • Thanks for reply. Yes I am using storyboard. I tried that option what you suggested but as I am using ecslidingviewcontroller for navigation and sliding, the method you mentioned works only for the first time when i launch the app and click on row. I have different view controllers under the detail and MainViewController which shows menu for my app. – Suhit Patil Jul 26 '13 at 09:07
  • I have done an app which uses ECSlidding and I have lots of collection views and tables that push to other views. I thought I used this method but maybe it is something else that is messing it up. I will find the code and check... – Recycled Steel Jul 26 '13 at 09:38
  • Added another EDIT, another option but not sure how it will turn out. – Recycled Steel Jul 26 '13 at 09:41
  • Thanks Recycled Steel, the code u posted is not doing any animation. it is similar to the one I posted in my question – Suhit Patil Jul 26 '13 at 13:26
  • Yep did not think it would. I will have to look over my code but it is broken at present. Note that doing it by segue only allows the standard twist and so on methods of transition - is this okay or do you want it to "swipe" like the menu? – Recycled Steel Jul 26 '13 at 15:52
  • I want the transition like push or vertical. swipe effect is not important as i am doing transition in didSelectRowAtIndexPath: method. I tried earlier option of segues but it's not working for me and I don't want any back button on details view cos i have my menus in either side below detailsviewcontroller and i have menu button in left and right side. – Suhit Patil Jul 27 '13 at 06:06