SWRevealViewController - RightViewController
I figured out what the problem was. In loadStoryboardControllers
method [self performSegueWithIdentifier:SWSegueRightIdentifier sender:nil];
was commented out. If we implement right view controller this has to be uncommented.
SWRevealViewController rightViewController disable the opening
You have to check the pan gesture's direction:
- (BOOL)revealControllerPanGestureShouldBegin:(SWRevealViewController *)revealController {
if ([revealController.panGestureRecognizer velocityInView:revealController.view].x < 0) {
// pan direction left, should open right side
// ...
return NO;
}
return YES;
}
SWRevealViewController from the right side on swift
I followed this solution, in the controller of the front siding view use this:
override func viewDidLoad() {
super.viewDidLoad()
if self.revealViewController() != nil {
favoritesButton.target = self.revealViewController()
favoritesButton.action = "rightRevealToggle:"
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
}
Don't forget to create the Outlet to the item bar button first. In the storyboard, set the segue value to sw_right
And first that didn't work for me, but a clean helped.
SWrevealViewController without using navigationController
where you need to push or model new view controller call the below code
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"yourstoryboardname" bundle: nil];
UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"yourIDName"];
[[self navigationController] pushViewController:viewController animated:NO];
SWRevealViewController FrontViewController not loading, stuck as Black, other views fine
I had the same thing going on. I fixed it while looking on the Example code.
- In your Storyboard add a UIViewController
- Select it and in Identity Inspector just use 'SWRevealViewController' as class
- Add a UITableViewController to your story board
- Now select your previously added ViewControler and right-click-draw a line to your TableViewController
- Select 'reveal view controller set controller'
- Click on the newly added Segue and in Attribute Inspector change the identifier to 'sw_rear'
- Add any custom ViewController (for example 'MyViewController') to the story board
- Select it, then go to the Menu->Editor->Embed In->Navigation Controller
- Now a new Navigation Controller should appear
- Again right-click-draw a line from the first ViewController to your new NavigationController
- Again choose 'reveal view controller set controller'
- Now set the identifier of this new Segue to 'sw_front'
Now you have a Basic Setup and when running your app, you should see your custom ViewController. Now the Button for the Menu has to be added.
In your ViewControllers .m add following:
@interface MyViewController ()
@property (nonatomic) IBOutlet UIBarButtonItem* revealButtonItem;
@end
- (void)viewDidLoad {
[super viewDidLoad];
[self customSetup];
}
- (void)customSetup
{
SWRevealViewController *revealViewController = self.revealViewController;
if ( revealViewController )
{
[self.revealButtonItem setTarget: self.revealViewController];
[self.revealButtonItem setAction: @selector( revealToggle: )];
[self.navigationController.navigationBar addGestureRecognizer: self.revealViewController.panGestureRecognizer];
}
}
Now again switch to the story board. Add a UIBarButtonItem to MyViewController. Again right-click-draw a line from MyViewController to this new item in the NavigationBar. Choose 'revealButtonItem'.
Thats it! Repeat the last steps for every ViewController you want to add. You only have to connect them with right-click-drawing from the TableView to your newly added NavigationController of each of your added ViewControllers. To push the ViewControllers just select 'reveal view controller push controller'.
Hope that helps a bit!
Login View controller before SWRevealViewController
In apps with user sessions, it is usually best to keep login/signup on a separate view hierarchy from the rest of the app and present the internal structure if there is an active session. You can achieve this by checking for
[PFUser currentUser]
as it will return nil
if the user is not logged in.
Provide a check in your AppDelegate like so:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// .. Rest of your initialization code
if ([PFUser currentUser]) {
// Let's pop them right to the home screen
[self showHomeScreen];
}
else {
// Present login vc
LoginView *lv = [[LoginView alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:lv];
self.window.rootViewController = nav;
}
return YES;
}
- (void)showHomeScreen {
SidebarViewController *sbvc = [[SidebarViewController alloc] init];
UINavigationController *menuVC = [[UINavigationController alloc] initWithRootViewController:sbvc];
UIViewController *home = [[UIViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:home];
SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:menuVC frontViewController:nav];
self.window.rootViewController = revealController;
}
Then, by including
- (void)showHomeScreen;
in AppDelegate.h
, you can call this method upon successful registration/login:
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate showHomeScreen];
SWRevealViewController right side menu
With the help of
Center Align text in UITableViewCell problem
modified for right instead of center I was able to get the menu to align to the right and final code is below.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
NSInteger row = indexPath.row;
if (nil == cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.textLabel.textAlignment = NSTextAlignmentRight;
}
return cell;
}
Related Topics
How to Create an Nsdecimal Without Using Nsnumber and Creating Autoreleased Objects
Firestore Paginating Data + Snapshot Listener
How to Determine If a User Has an iOS App Installed
Optional Binding Succeeds If It Shouldn'T
Shrink Large Title When Scrolling (Not Uitableviewcontroller) iOS 11
How Long Does a Push Notification Sit in Queue Before Being Removed
Nearby Bluetooth Devices Using Swift 3.0
Why Does Unexpected Non-Void Return Value in Void Function Happen
Facebook App Invites Notification Not Working in iOS
Get the Callers Phone Number from an Incoming Call on Iphone
How to Release an Mtaudioprocessingtap
Xcode 5/iOS 7 - Localization Not Working in Simulator
Using Sysctlbyname() from Swift
How to Create a PDF File Programmatically in an iOS Application
Asynchronous Upload with Nsurlsession Will Not Work But Synchronous Nsurlconnection Does
Set<Nsobject>' Does Not Have a Member Named 'Anyobject." - Xcode 6.3