|
|
@@ -15,7 +15,9 @@ static NSString *kRememberLogin = @"RememberLogin";
|
|
|
static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
|
|
|
@interface LoginViewController ()<UITableViewDelegate,UITableViewDataSource,LoginSwitchDelegate,UITextFieldDelegate>
|
|
|
-
|
|
|
+{
|
|
|
+ BOOL _autoShowSetting;
|
|
|
+}
|
|
|
@property (strong, nonatomic) IBOutlet UITableView *loginTable;
|
|
|
@property (nonatomic,strong) NSDictionary *dataDic;
|
|
|
@property (strong, nonatomic) IBOutlet UILabel *versionLabel;
|
|
|
@@ -33,7 +35,7 @@ static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
// Do any additional setup after loading the view.
|
|
|
-
|
|
|
+ _autoShowSetting = NO;
|
|
|
[self initUserData];
|
|
|
[self loadData];
|
|
|
[self.loginTable reloadData];
|
|
|
@@ -48,6 +50,14 @@ static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
self.versionLabel.text = [NSString stringWithFormat:@"Ver: %@.%@",short_version,build];
|
|
|
}
|
|
|
|
|
|
+- (void)viewDidAppear:(BOOL)animated {
|
|
|
+ [super viewDidAppear:animated];
|
|
|
+ if (_autoShowSetting) {
|
|
|
+ [self settingBtnClick:self.settingBtn];
|
|
|
+ _autoShowSetting = NO;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
[super didReceiveMemoryWarning];
|
|
|
@@ -56,6 +66,15 @@ static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
|
|
|
#pragma mark - Private
|
|
|
|
|
|
+- (void)setAddress:(NSString *)address {
|
|
|
+ _address = address;
|
|
|
+ if (!address.length) {
|
|
|
+ _autoShowSetting = YES;
|
|
|
+ } else {
|
|
|
+ _autoShowSetting = NO;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
- (void)loadData {
|
|
|
NSString *path = [[NSBundle mainBundle] pathForResource:@"login.json" ofType:nil];
|
|
|
NSData *data = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedIfSafe error:nil];
|
|
|
@@ -75,6 +94,12 @@ static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (!self.address.length){
|
|
|
+ _autoShowSetting = YES;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _autoShowSetting = NO;
|
|
|
+
|
|
|
NSDictionary *userData = [self userDefaultsValue:kLoginUserInfo];
|
|
|
if (userData) {
|
|
|
// self.address = [userData objectForKey:@"address"];
|
|
|
@@ -223,7 +248,7 @@ static NSString *kLoginUserInfo = @"UserInfo";
|
|
|
LoginSettingViewController *loginSettingVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginSettingViewController"];
|
|
|
__weak typeof(self) weakself = self;
|
|
|
loginSettingVC.returnValue = ^(NSString *address) {
|
|
|
- if (weakself && address.length) {
|
|
|
+ if (weakself) {
|
|
|
__strong typeof(weakself) strongself = weakself;
|
|
|
strongself.address = address;
|
|
|
[strongself.loginTable reloadData];
|