Comments (6)
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.
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.
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.
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.
If you have a simple project that I can test I will have a look at it.
from saslidemenu.
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)
- calling a method when a menuitem is tapped? HOT 3
- make status bar overlap leftMenu HOT 6
- provide initial segue which does not have a menu cell in the tableview HOT 2
- Swipe close menu HOT 2
- Whats the best way to add a Header to the (left)menu HOT 4
- Can I show another ViewController from different story board? HOT 6
- How to control interface orientation? HOT 6
- How to use SASideMenu with Tabbar Controller HOT 4
- How I can detect when the user click the menu icon?
- Gesture on Close Slide (Disable)
- Update from version 1.2.1 to 2.0.3 -> tableView:cellForRowAtIndexPath: not call HOT 2
- How I can manage status bar like GMail? HOT 3
- Slide Menu Tremor HOT 5
- Close Menu Programmatically
- The left Menu shifts down when in call? HOT 2
- Parallax effect? HOT 1
- Not working in iOS 10
- Show left menu as default screen
- Support for Swift Package Manager
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from saslidemenu.