Giter Club home page Giter Club logo

Comments (6)

mradlmaier avatar mradlmaier commented on July 17, 2024

I have tried several things:

  • Implemented "shouldPerformSegueWithIdentifier" in my MenuViewController. This method is calles (as NSLog shows), but segues are always performed independent of returning YES or NO.

  • Modified "didSelectRowAtIndexPath" in SASlideMenuViewController as follows:

    NSUserDefaults defaults = [NSUserDefaults standardUserDefaults];
    NSString
    segueId = [self.slideMenuDataSource segueIdForIndexPath:indexPath];

    NSLog(@"didSelectRowAtIndexPath");
    NSLog(@"login_active: %hhd", [defaults boolForKey:@"login_active"]);
    NSLog(@"segueId: %@", segueId);

    if ([defaults boolForKey:@"login_active"]) {
    NSLog(@"perform segue");
    [self loadContentAtIndexPath:indexPath];
    } else if(![defaults boolForKey:@"login_active"] && ![segueId isEqualToString:@"ausloggen"]){
    NSLog(@"perform logout");
    [self loadContentAtIndexPath:indexPath];
    } else if (![defaults boolForKey:@"login_active"] && [segueId isEqualToString:@"ausloggen"]){
    NSLog(@"DONT perform logout");
    return;
    }

This had no effect neither. The method is always called, but either it always causes the segues or always doesn't cause segue no matter what the value of [defaults boolForKey:@"login_active"] is...

from saslidemenu.

stefanoa avatar stefanoa commented on July 17, 2024

Have you tried to use the UITableViewDelegate method:

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath

If you return nil tha cell should not be selectable and the segue should not be fired.

from saslidemenu.

mradlmaier avatar mradlmaier commented on July 17, 2024

I will try that, thanks
Cheers,
Michael

Von meinem iPhone gesendet

Am 15.06.2014 um 12:57 schrieb stefanoa [email protected]:

Have you tried to use the UITableViewDelegate method:

  • (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
    If you return nil tha cell should not be selectable and the segue should not be fired.


Reply to this email directly or view it on GitHub.

from saslidemenu.

mradlmaier avatar mradlmaier commented on July 17, 2024

I implemented it like you suggested:

  • (NSIndexPath )tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString
    segueId = [self.slideMenuDataSource segueIdForIndexPath:indexPath];
    NSLog(@" ");
    NSLog(@"willSelectRowAtIndexPath");
    NSLog(@"login_active: %hhd", [defaults boolForKey:@"login_active"]);
    NSLog(@"segueId: %@", segueId);
    NSLog(@"indexPath: %@", indexPath);
    if ([defaults boolForKey:@"login_active"]) {
    // perform all segues
    NSLog(@"login_active:YES, perform all segues");
    return indexPath;
    } else {
    // perform all segues except "ausloggen"
    if ([segueId isEqualToString:@"ausloggen"]) {
    NSLog(@"login_active:NO, DONT perform ausloggen/logout");
    return nil;
    } else {
    NSLog(@"login_active:NO, perform this segue");
    return indexPath;
    }
    }
    }

But:
If I disable the logout, terminate the app, restart the app, the app will correctly start with out displaying the login controller. Then I enable the logout in the settings controller, and then try to logout, it does not perform the segue as it should, although the logs show, that the user defaults are correctly set, and the indexPath is the one of the logout cell, and even the respective if - branch is executed.
Note: I am using an unwind segue for the logout, because I want that the stack of view controllers is correctly cleared (I fear memory leaking/memory growth unlimited).

The idea is that I have a login to secure sensitive data stored in the app, but that the user can opt out of logging in, if he chooses, too.

from saslidemenu.

stefanoa avatar stefanoa commented on July 17, 2024

If you have a simple project that I can test I will have a look at it.

from saslidemenu.

mradlmaier avatar mradlmaier commented on July 17, 2024

This project is not simple, it has many View Controllers. I would have to setup an example.

But what I have found, is, if I use a normal segue instead of an unwind segue, it works.

My theory is, that unwind segues can only segue to previously presented/executed view controllers, not to any view controller in the storyboards. At least that is my observation:

--> User logins and out --> this works

--> User logins, disables login, closes app, opens app, (no login view controller presented), enables login --> unwind segue doesn't work
--> User logins, disables login, brings app into background, brings app into foreground again, enables login --> unwind segue works

Obviously unwind segue to the login vc only works, if the login vc was previously open.

I wanted to use unwind segues, because my app has many view controllers, and I wanted that, when the user logs out, memory occupied by a huge stack of controllers is freed ;-)

from saslidemenu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.