Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segue to proper tab of tabbar (front view) from rear view. #563

Closed
iosdev27 opened this issue Mar 23, 2016 · 40 comments
Closed

Segue to proper tab of tabbar (front view) from rear view. #563

iosdev27 opened this issue Mar 23, 2016 · 40 comments

Comments

@iosdev27
Copy link

I have the following storyboard setup (see attached screenshot).
screen shot 2016-03-23 at 4 44 46 pm

It's a fairly simple setup, where I have a tabbarcontroller as the frontviewcontroller with two tabs. I want to be able to segue to the proper tab from the rear view (which is the menu table view).

Here is what I'm currently doing:

  1. In the rear view's uitableview
  • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView reloadData];

    if (indexPath.row == 1 || indexPath.row == 2) {
    [self performSegueWithIdentifier:@"toTabBarSegue" sender:indexPath];
    }
    }

  • - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([[segue identifier] isEqualToString:@"toTabBarSegue"]) {
    if ([sender isKindOfClass:[NSIndexPath class]]) {
    NSIndexPath *indxPath = (NSIndexPath *)sender;
    TabBarViewController *tBVC = segue.destinationViewController;
    tBVC.selectedIndex = indxPath.row;
    }
    }
    }
    Problem: This segues to the proper tab but the menu gesture stops working. Also the the state of the tab is reloaded to initial settings. So my question is, what is the best way to load a particular tab with previous state from rear view (menu) uitableview?

Any help is much appreciated!

@iDevelopper
Copy link

Hello,

Is it what you want?

SWTabBar.zip

@iosdev27
Copy link
Author

Yes, this did it! Thank you very much.

@iosdev27
Copy link
Author

Hi, I have one more question. When we segue back to the frontcontroller from the menu, is it possible to pop a uiviewcontroller that is currently on the frontcontroller? I have a scenario where something gets pushed on the frontcontroller (in this case, one of the tabs from the tabbar), so when I go back to it from the menu I want that added VC to be popped off. Thanks.

@iosdev27 iosdev27 reopened this Mar 26, 2016
@iDevelopper
Copy link

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

SWTabBar 2.zip

@iosdev27
Copy link
Author

That works, thanks!

@iDevelopper
Copy link

Perhaps, it is better not to animate:

[navController popToRootViewControllerAnimated:NO];

@thihaaung6245
Copy link

@iDevelopper,Thanks for your help,Any help for swift version for SWTabBar 2.zip?

Also,one question,how to disable slide menu on some view?Means at some view i want to disable the slide menu and its gesture but,i want to enable back swipe feature. At the SWTabBar 2.zip you shown how to push view controller,but,it disable on gesture swipe for drawer appearance on view.But,not at navigation bar.Try swiping from navigation bar and you will see the menu appear on push segue view.

Thanks for your sample project.

@iDevelopper
Copy link

@htarwara6245 , I'm not strong enough in swift

if you want to disable a gesture:

[self.navigationController.view removeGestureRecognizer:self.revealViewController.panGestureRecognizer];

@thihaaung6245
Copy link

ok,Thanks,If i got an answer,I will share it here.

@iDevelopper
Copy link

Perhaps this should help :

https://apps.myappconverter.com

@iDevelopper
Copy link

But if you know swift it is not very complicated to translate the code as each objective-c method has an equivalent in Swift

@iDevelopper
Copy link

@htarwara6245 , I have not managed to use MyAppConverter. So I followed a tutorial and following a swift version of my example :

SWTabBarSwift.zip

Tell me what!

@thihaaung6245
Copy link

Thanks for the help.Currently.I only have Xcode 9.2 at my mac.But,I will try to reply u back when i got Xcode 7.3.Thanks for giving me some time.:D.

@thihaaung6245
Copy link

@iDevelopper ,it really worked!!!I mean the swift version u gave to me...Thanks for the excellent example you supported.Sorry about my late reply.Thank you.

@iDevelopper
Copy link

This is the last version:

SWTabBarSwift 2.zip

@thihaaung6245
Copy link

thihaaung6245 commented Apr 22, 2016

@iDevelopper ,I want to create something more creative.Assume we got table view on each tab bar item.
Each table cell got its own view.Creating push segue from UITabBar is ok.But,from slide menu,its not.

Please check my new project
SWTabBarSwift[New Modified].zip

When we navigate from slide menu to other view controller that is not in reveal controller,there is no back button because when we make back segue it could turn to left menu.Please take a look at my project.There might be some crash on navigation on item 1 and 2 slide items.

What i want?
Is the same flow like that

UITabBarController(Item 1) got UITableViewController -> Tap Classic - >Go to classic view,when back from classic,back to UITabBarController.

Same flow on Slide menu
Slide Menu - > Tap Classic - > go to classic View ->When make back swipe,it should back to its own existed tab item 1.

Please ask me if u feel complex about that,A little help if u have some time?

@iDevelopper
Copy link

@htarwara6245 , I looked and changed the project but I ask myself the question why you want to do that. Come back on a view where the user did never passed!

As you do that can not work. You instantiate the final view controller to push it, so nothing in the stack to return.

I modified in MenuTableViewController, in didSelectRowAtIndexPath. Hope I understood!

I deleted the add Tap an Pan Gesture in the view controllers. Just need to do that in RevealViewController class. You deleted a part of rightViewController. I did not care.

SWTabBarSwift 3.zip

@thihaaung6245
Copy link

thihaaung6245 commented Apr 22, 2016

Yeah,I asked myself,too.This is ridiculous.Actually this app design is similar to Google + app.But,the client wants to navigate the item inside tab from slide menu which was non-sense.

But,I really appreciate that you gave some time to help me out,Thank you.:) Sorry for my late reply I just got home from work.

@thihaaung6245
Copy link

thihaaung6245 commented Apr 23, 2016

@iDevelopper ,I got some question to ask.Its about library.

1.How do i disable the swipe gesture when i was at Classic View?I only want to enable the swipe gesture meant for back swipe.Not the drawer appearance swipe.Centure Pan Gesture.

2.How to make menu not stretch when i swipe it?

3.How to make menu navigation animation disable and do like normal slide menu.

4.How to disable menu bounce?

@iDevelopper
Copy link

@htarwara6245 ,

RevealViewController.swift.zip

@thihaaung6245
Copy link

thihaaung6245 commented Apr 24, 2016

No.1 I solve the problem like that,

But,while I am testing my application I found that black screen appear everytime i swipe the slide menu multiple time between rear view and front view

I fixed that bug like that.At the RevealViewController,I added the following code
self.toggleAnimationType = .EaseOut

And I want another solution too,hope you can help me,
#576

Thanks for all the help u gave me all the way.

@iDevelopper
Copy link

I'll write a sample

@iDevelopper
Copy link

What about this?

SWFrontMenu.zip

@thihaaung6245
Copy link

@iDevelopper,I got one final question to ask.

Because my app gonna release soon.Is there any way that i can disable font view(Tab Bar) user interaction when the reveal view (Left Menu) appear?

Thanks
With Regards

@thihaaung6245
Copy link

thihaaung6245 commented May 8, 2016

I got it now.At my front view,I mean every front view.I extended SWRevealViewControllerDelegate and at viewDidLoad(),added two line of codes

    self.revealViewController().delegate = self
    self.revealViewController().panGestureRecognizer()

and added two delegate methods,

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

func revealController(revealController: SWRevealViewController, didMoveToPosition position: FrontViewPosition){
    if(position == FrontViewPosition.Left) {
        self.view.userInteractionEnabled = true
    } else {
        self.view.userInteractionEnabled = false
    }
}

If there is a better way,Any suggestion is appreciated.

And Thanks for all your help you gave me all the way.

@thihaaung6245
Copy link

thihaaung6245 commented May 8, 2016

Nah that didnt work....When i implement the above way,this function at SWRevealController stop working

``
func revealControllerPanGestureShouldBegin(revealController: SWRevealViewController!) -> Bool {
let tabController = revealController.frontViewController as! UITabBarController
let navController = tabController.viewControllers![tabController.selectedIndex] as! UINavigationController
let controller = navController.topViewController

    if controller!.isKindOfClass(LanguageViewController.classForCoder()) {
        return false
    }
    if controller!.isKindOfClass(SettingsViewController.classForCoder()) {
        return false
    }
    return true
}

``

@iDevelopper
Copy link

Do like in this sample. Add in RevealViewController subclass the two methods tapGestureRecognizer and panGestureRecognizer in viewDidLoad. Delete the viewWillAppear in each front controller.

SWTabBarSwift 5.zip

@thihaaung6245
Copy link

thihaaung6245 commented May 8, 2016

I can't delete viewWillAppear at each front controller because there are some async network call method at viewWillAppear on each Front View Controllers.So,Its there any other way?I have to tell you something that when i tried add this code at My RevealViewController.

http://puu.sh/oKMm2/f30c2de909.png

When i clicked menu item which was at reveal view controller,it animated a little faster than normal i guess.But,it worked now.no more user interaction on front view controller and i didn't need to remove ViewWillAppear on each Front View Controller.

@iDevelopper
Copy link

And do not set a delegate for sw elsewhere than in RevealViewController subclass!

@thihaaung6245
Copy link

thihaaung6245 commented May 18, 2016

My client wants something new again.Assume we got 4 tab bar items at UITabBarController.Assume 4 Main Categories for now.But,he want to add new Home View Screen.When the app load the TabbarController.I want to show HomeViewController.But,I want all 4 tabbaritems to be deselected.Means i want to make home view controller with slide menu as root view controller and want to show tab bar at home view.But,wants to deselect all tabbaritems at home view.Can I make it like that?

More Simply.
1.Setting HomeViewController with slide menu and TabBarItems(All Unselected)
2.HomeViewController doesn't concerned with TabBarItems(4 Categories).It was just a view which include slide menu and tabbarcontroller(all unselected)

Any Help?I am also trying to figure this out.If you have anytime,can you help me?@iDeveloper

@iDevelopper
Copy link

I don't understand. What is for the HomeViewController? You can't have a TabBarController with no item selected...

@thihaaung6245
Copy link

thihaaung6245 commented May 18, 2016

Mind please take a look at Google + app on iOS.And when you open slide menu,choose Profile.You will see No tabBarItem is selected when it showed profile View.My Idea is same like that.But,different is I want to show Profile as RootViewController with no tabbarItem selected.If i choose "Home",it should select home to.You will see what i am talking about when u use that app.Thanks

Regards.

@iDevelopper
Copy link

iDevelopper commented May 18, 2016

I think they don't use a TabBarController but just a TabBar and at this moment the can do tabBar.selectedItem = nil which is not allowed if the tabBar is managed by a tabBarController

@thihaaung6245
Copy link

Can you help me find this out with UITabBarController?because i set the whole project with UITabBarController on storyboard.;(

@iDevelopper
Copy link

iDevelopper commented May 18, 2016

You could set a color for unselected items and a tint color for selected item and when you want no item selected, change the tint color to the same color of unselected item.

    tabBarController.tabBar.tintColor = the color of unselected items

@thihaaung6245
Copy link

thihaaung6245 commented May 18, 2016

If I can work with UITabBar,would you provide an example of my above requirement with UITabBar with reveal controller which i can push from each tab as well as from slide menu?Please?

@iDevelopper
Copy link

The best way will be to use container views, have a look!

@iDevelopper
Copy link

iDevelopper commented May 21, 2016

Here is a sample:

SWTabBarSwift2.zip

@thihaaung6245
Copy link

Thanks for the help,I just tell my client that I have to add new Home Tab instead before your answer come in.Anyway,really thanks for your help all these way even that is not concerned with this library.

@thihaaung6245
Copy link

@iDevelopper,I know this one is close,so I would like to post a new question which need your support :

#646

Any Help?Its about navigating to each screen inside left menu or tabbaritem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants