John-Lluch / SWRevealViewController

A UIViewController subclass for presenting side view controllers inspired on the FaceBook and Wunderlist apps, done right !
Other
4.52k stars 989 forks source link

SWRevealViewControllerSeguePushController with UITabBarContrller #633

Open user2233 opened 7 years ago

user2233 commented 7 years ago

I have a project working with the RevealController as initial VC, the "hamburger" slide-in sidebar as the rear VC and a UITabBar Controller as the frontVC displaying content. Everything works fine up to that point.

In storyboard I have segues from menu buttons to the target View Controllers set to SWRevealViewControllerSeguePushController as suggested int he documentation. The target VCs are embedded in navigation controllers to show the toolbar items and before tapping you see the toolbar items in the toolbar. The problem is once you tap a button and segue to a target VC, items in the toolbar disappear. If I change the segues to show, then toolbar items do show up on segue, however, the reveal functionality is lost and you cannot retrieve the sidebar menu.

Might there be a switch in the project to display the toolbars? Or can anyone suggest a way to preserve access to the item icons in the toolbar after performing a SWRevealViewControllerSeguePushController segue?

iDevelopper commented 7 years ago

I have a sample for this:

SWTabBarSwift.zip

user2233 commented 7 years ago

Great project. Unfortunately for me, I have not yet learned Swift. Looks like you are just using regular push controllers to the targets. Could you explain approach or what you modified to get it to work?

iDevelopper commented 7 years ago

I have an other one written in Objective-c:

SWTabBar.zip

user2233 commented 7 years ago

Patrick, great project. I haven't learned Swift so can't immediately figure out what you did. Would you mind describing what you have done to get it to work?

Looks like you are using "Show" Segues, not the RevealPush ones. How are you preserving the SWReveal functionality once you go to the regular menu?

On Mon, Oct 24, 2016 at 10:14 AM, Patrick notifications@github.com wrote:

I have a sample for this:

SWTabBarSwift.zip https://github.com/John-Lluch/SWRevealViewController/files/548057/SWTabBarSwift.zip

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/John-Lluch/SWRevealViewController/issues/633#issuecomment-255752139, or mute the thread https://github.com/notifications/unsubscribe-auth/AV84byWkvZXkwEhYqanAG7rojTdX6-t2ks5q3L0wgaJpZM4KeOt- .

iDevelopper commented 7 years ago

Did you watch the last project written in Objective-c? I don't use segue to push the front view controllers (but it is the same), I use programmatically (in MenuTableViewController.m, the rear view controller):

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITabBarController *tabBarController = (UITabBarController *)self.revealViewController.frontViewController;
    UINavigationController *navController = tabBarController.viewControllers[indexPath.row];
    [navController popToRootViewControllerAnimated:NO];
    tabBarController.selectedIndex = indexPath.row;
    [self.revealViewController pushFrontViewController:tabBarController animated:YES];
}
user2233 commented 7 years ago

Yes, thanks so much. Using the delegate method did the trick and tabs now showing on push. Am still struggling with passing data, however. myVC * destVC = [navController.viewControllers objectAtIndex:0]; destVC.data = @"Data Point"; is not doing it.

iDevelopper commented 7 years ago

This is not a SW issue, but:

The front view controller is a UITabBarController. The myVC is embedded in a UINavigationController who is embedded in the UITabBarController:

UITabBarController -> UINavigationController -> myVC, then

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITabBarController *tabBarController = (UITabBarController *)self.revealViewController.frontViewController;
    UINavigationController *navController = tabBarController.viewControllers[indexPath.row];
    UIViewController *vc = navController.topViewController;
    if ([vc isKindOfClass:[ViewController2 class]]) {
        ((ViewController2 *)vc).data = @"Data";
    }
    [navController popToRootViewControllerAnimated:NO];
    tabBarController.selectedIndex = indexPath.row;
    [self.revealViewController pushFrontViewController:tabBarController animated:YES];
}

SWTabBar 2.zip

user2233 commented 7 years ago

That works great for VC 2. Can't get it to work for VC1. Could this be because VC1 is already loaded would need to be reloaded?

iDevelopper commented 7 years ago

Subclass SWRevealViewController (RevealViewController in the sample), donc forget to set this class in the storyboard for SW and implement prepareForSegue:

SWTabBar 3.zip

user2233 commented 7 years ago

This lets you preset the data on load. Still can't figure out how to push data dynamically from menu to the VC originally in stack. For example, if you have a table of books and want the menu to list authors so the table would then show books by the selected author.

iDevelopper commented 7 years ago

You have just to keep a reference to your controller in a property or with a protocol. But I don't really understand, in didSelectRowAtIndexPath, it is done. Can I have a look at your storyboard?

YouSour commented 6 years ago

good but it need entry point to start on that view controller first how about i have other view controller i need to start it first , how can i fix it ?

iDevelopper commented 6 years ago

Insert another view controller as the entry point and instantiate SWRevelViewController from it when needed. What is the problem?

YouSour commented 6 years ago

ok , it work now , @iDevelopper , but when i have segue from table cell to UI tab bar controller item disappeared ?

iDevelopper commented 6 years ago

Can you attach your project here?

YouSour commented 6 years ago

Home-tutor here @iDevelopper

iDevelopper commented 6 years ago

404 not found! Upload it here...

YouSour commented 6 years ago

Home_Tutor-master-89ba190111341eba76187c6e8cb5e44397098143.zip here @iDevelopper

iDevelopper commented 6 years ago

Ok, got it, but in your project there no segue between your table view and another controller?

YouSour commented 6 years ago

why don't you try add segue from table view to navigation controller of profile view controller you will see tab bar disappeared . @iDevelopper

iDevelopper commented 6 years ago

Ok, you have to push the tab bar controller (witch is the front view controller) and select his correct index. See LeftTableViewController.swift. I added also TutorSearchViewController and TutorNotificationsViewController.swift.

Home_Tutor-master-89ba190111341eba76187c6e8cb5e44397098143.zip

YouSour commented 6 years ago

wow , you 're good person @iDevelopper thank you so much , you save me :)