Swrevealviewcontroller - Rightviewcontroller

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

Xcode 7 Beta 6 Screenshot

And first that didn't work for me, but a clean helped.

SWrevealViewController without using navigationController

Sample Image

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.

  1. In your Storyboard add a UIViewController
  2. Select it and in Identity Inspector just use 'SWRevealViewController' as class
  3. Add a UITableViewController to your story board
  4. Now select your previously added ViewControler and right-click-draw a line to your TableViewController
  5. Select 'reveal view controller set controller'
  6. Click on the newly added Segue and in Attribute Inspector change the identifier to 'sw_rear'
  7. Add any custom ViewController (for example 'MyViewController') to the story board
  8. Select it, then go to the Menu->Editor->Embed In->Navigation Controller
  9. Now a new Navigation Controller should appear
  10. Again right-click-draw a line from the first ViewController to your new NavigationController
  11. Again choose 'reveal view controller set controller'
  12. 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



Leave a reply



Submit