Swrevealviewcontroller - Manually Switch to Another View

SWRevealViewController - manually switch to another view?

Use
- (void)setFrontViewController:(UIViewController *)frontViewController animated:(BOOL)animated; method

SWRevealController has it's own property you can access from any UIViewController:

SWRevealViewController *revealController = self.revealViewController;

You can check example projects at it's GitHub repository:
https://github.com/John-Lluch/SWRevealViewController

SWRevealViewController from one controller to another

As @Anbu.Kathik explained I could not use the SWReveal to move from Controller to another Controller. I've solved it by using the same TableViewController, I've added a property type to check which is the current 'tableview' and simply updating the table when an item is selected on didSelectRowAtIndexPath.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// check type of current tableview - if category display article
if ([self.type isEqualToString:@"category"]) {
// display single article
_selectedArticle = _feedItems[indexPath.row];
[self performSegueWithIdentifier:@"detailSegue" sender:self];
}
else {
// else if issue display list of articles on the same TableViewController
_selectedIssue = _feedItems[indexPath.row];
self.type = @"category";
self.data = [_selectedIssue.ID stringValue];
[_homeModel downloadItems:self.type :self.data];
}
}

Using [self.tableView reloadData] reloads the table with new data.

SWRevealViewController - Prevent Interacting With The Back View

well I has been working with/on SWRevealViewController for a while
so what you need is add your frontViewController as SWRevealViewControllerDelegate and then implementing this function

func revealController(revealController: SWRevealViewController!, willMoveToPosition position: FrontViewPosition)

you will be notified when frontViewController go to left or to front position

this is the Swift code

in your frontViewController you need to add

class FrontViewController: UIViewController, SWRevealViewControllerDelegate
{
override func viewDidLoad() {
super.viewDidLoad()
self.revealViewController().delegate = self;
}

//YOUR CODE//

func revealController(revealController: SWRevealViewController!, willMoveToPosition position: FrontViewPosition) {
if(position == FrontViewPosition.Left)
{
self.view.userInteractionEnabled = true;
self.navigationController?.navigationBar.userInteractionEnabled = true;
}else
{
self.view.userInteractionEnabled = false;
self.navigationController?.navigationBar.userInteractionEnabled = false;

}
}

//EDITED

This is the Objective C code

class FrontViewController: UIViewController <SWRevealViewControllerDelegate>

in the viewDidLoad you need to add

- (void)viewDidLoad
{
[super viewDidLoad];
self.revealViewController.delegate = self;
}

//YOUR CODE//

- (void)revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position
{
if(position == FrontViewPositionLeft)
{
self.view.userInteractionEnabled = NO;
self.navigationController.navigationBar.userInteractionEnabled = NO;
}else{
self.view.userInteractionEnabled = YES;
self.navigationController.navigationBar.userInteractionEnabled = YES;
}
}

I hope this help you

SWRevealViewController - push next view controller storyboard

It seems ViewController2 is a ViewController in storyboard. Try the below code:

ViewController2 * vc2 = [[self storyboard] instantiateViewControllerWithIdentifier:@"ViewControllerId"];

You should give Storyboard ID for ViewController2 as ViewControllerId in your storyboard.

Please note that your current ViewController should be in a Navigationcontroller stack to call self.navigationcontroller.



Related Topics



Leave a reply



Submit