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
How to Disable User Interaction on Mkmapview
_Unused Flag Behavior/Usage (Gcc with Objective-C)
Uirefreshcontrol Stuck After Switching Tabs in Uitabbarcontroller
Xcode 6.4/7 Crashing After El Capitan Beta
Detect Tap on Calloutbubble in Mkannotationview
How to Detect an iOS App Installed or Upgraded
Endless Scrolling Background in Spritekit
Custom View Which Looks Like Uialertview
Not Receiving Any Push Notification in Iphone
Storyboard Navigation Controller and Tab Bar Controller
How to Use the Default iOS7 Uianimation Curve
Push View Programmatically in Callback, Swiftui
"Unable to Validate Your Application Error" While Uploading a New Version of iOS App
Best Way to Save and Retrieve Uicolors to Core Data
Xcode: Any Way to Refresh/Re-Run the Playground