Sfoglia il codice sorgente

1.完成RootVC功能。
2.构建POP模式视图。

Pen Li 9 anni fa
parent
commit
d60853119b

+ 6 - 0
RA Image/BasicViewController.h

@@ -13,10 +13,16 @@
 #import "AppDelegate.h"
 #import "RAUtils.h"
 
+extern NSString *const LogoutNotification;
+
 @interface BasicViewController : UIViewController
 
+@property (nonatomic,strong,readonly) NSNotificationCenter *notificationCenter;
+
 - (id)userDefaultsValue:(NSString *)key;
 
 - (void)setUserDefaultsValue:(id)value forKey:(NSString *)key;
 
+- (void)userLogout:(NSNotification *)notification;
+
 @end

+ 26 - 0
RA Image/BasicViewController.m

@@ -8,15 +8,31 @@
 
 #import "BasicViewController.h"
 
+NSString *const LogoutNotification = @"LogouNotification";
+
 @interface BasicViewController ()
 
 @end
 
 @implementation BasicViewController
 
+- (NSNotificationCenter *)notificationCenter {
+    return [NSNotificationCenter defaultCenter];
+}
+
+- (void)dealloc {
+    [self.notificationCenter removeObserver:self];
+}
+
+- (void)registNofitication {
+    [self.notificationCenter addObserver:self selector:@selector(userLogout:) name:LogoutNotification object:nil];
+}
+
 - (void)viewDidLoad {
     [super viewDidLoad];
     // Do any additional setup after loading the view.
+    
+    
 }
 
 - (void)didReceiveMemoryWarning {
@@ -36,5 +52,15 @@
     [userDefaults synchronize];
 }
 
+- (void)userLogout:(NSNotification *)notification {
+    if (self.presentedViewController) {
+        [self dismissViewControllerAnimated:NO completion:nil];
+        return;
+    }
+    if (self.navigationController) {
+        [self.navigationController popToRootViewControllerAnimated:NO];
+    }
+}
+
 
 @end

+ 46 - 0
RA Image/RA Image.xcodeproj/project.pbxproj

@@ -7,6 +7,10 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		426E6B1F1EB8558400942BE1 /* RootModeCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 426E6B1E1EB8558400942BE1 /* RootModeCell.m */; };
+		426E6B241EB85C2B00942BE1 /* PopModeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 426E6B231EB85C2B00942BE1 /* PopModeViewController.m */; };
+		426E6B271EB85C4200942BE1 /* ModelModeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 426E6B261EB85C4200942BE1 /* ModelModeViewController.m */; };
+		426E6B291EB8720400942BE1 /* Mode.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 426E6B281EB8720400942BE1 /* Mode.storyboard */; };
 		42E1B0FD1EB1C8EE00EEF27C /* LoginSwitchCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42E1B0FB1EB1C8EE00EEF27C /* LoginSwitchCell.m */; };
 		42E1B0FE1EB1C8EE00EEF27C /* LoginTextFiledCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 42E1B0FC1EB1C8EE00EEF27C /* LoginTextFiledCell.m */; };
 		42E1B1021EB1C92000EEF27C /* BasicViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42E1B1011EB1C92000EEF27C /* BasicViewController.m */; };
@@ -44,6 +48,13 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+		426E6B1D1EB8558400942BE1 /* RootModeCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootModeCell.h; sourceTree = "<group>"; };
+		426E6B1E1EB8558400942BE1 /* RootModeCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootModeCell.m; sourceTree = "<group>"; };
+		426E6B221EB85C2B00942BE1 /* PopModeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PopModeViewController.h; sourceTree = "<group>"; };
+		426E6B231EB85C2B00942BE1 /* PopModeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PopModeViewController.m; sourceTree = "<group>"; };
+		426E6B251EB85C4200942BE1 /* ModelModeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModelModeViewController.h; sourceTree = "<group>"; };
+		426E6B261EB85C4200942BE1 /* ModelModeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ModelModeViewController.m; sourceTree = "<group>"; };
+		426E6B281EB8720400942BE1 /* Mode.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Mode.storyboard; sourceTree = "<group>"; };
 		42E1B0F91EB1C8EE00EEF27C /* LoginSwitchCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginSwitchCell.h; sourceTree = "<group>"; };
 		42E1B0FA1EB1C8EE00EEF27C /* LoginTextFiledCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginTextFiledCell.h; sourceTree = "<group>"; };
 		42E1B0FB1EB1C8EE00EEF27C /* LoginSwitchCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginSwitchCell.m; sourceTree = "<group>"; };
@@ -122,6 +133,33 @@
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
+		426E6B1C1EB8555800942BE1 /* view */ = {
+			isa = PBXGroup;
+			children = (
+				426E6B1D1EB8558400942BE1 /* RootModeCell.h */,
+				426E6B1E1EB8558400942BE1 /* RootModeCell.m */,
+			);
+			name = view;
+			sourceTree = "<group>";
+		};
+		426E6B201EB85BD200942BE1 /* PopMode */ = {
+			isa = PBXGroup;
+			children = (
+				426E6B221EB85C2B00942BE1 /* PopModeViewController.h */,
+				426E6B231EB85C2B00942BE1 /* PopModeViewController.m */,
+			);
+			name = PopMode;
+			sourceTree = "<group>";
+		};
+		426E6B211EB85BFC00942BE1 /* ModelMode */ = {
+			isa = PBXGroup;
+			children = (
+				426E6B251EB85C4200942BE1 /* ModelModeViewController.h */,
+				426E6B261EB85C4200942BE1 /* ModelModeViewController.m */,
+			);
+			name = ModelMode;
+			sourceTree = "<group>";
+		};
 		42E1B0F71EB1C8BB00EEF27C /* Login */ = {
 			isa = PBXGroup;
 			children = (
@@ -179,6 +217,7 @@
 			children = (
 				71DCDC3D1EAF234E00BA045A /* RootViewController.h */,
 				71DCDC3E1EAF234E00BA045A /* RootViewController.m */,
+				426E6B1C1EB8555800942BE1 /* view */,
 			);
 			name = Root;
 			sourceTree = "<group>";
@@ -308,6 +347,9 @@
 			isa = PBXGroup;
 			children = (
 				71DCDC4F1EAF353000BA045A /* modelist.json */,
+				426E6B281EB8720400942BE1 /* Mode.storyboard */,
+				426E6B201EB85BD200942BE1 /* PopMode */,
+				426E6B211EB85BFC00942BE1 /* ModelMode */,
 			);
 			name = modes;
 			sourceTree = "<group>";
@@ -374,6 +416,7 @@
 				71DCDC471EAF234E00BA045A /* LaunchScreen.storyboard in Resources */,
 				71DCDC441EAF234E00BA045A /* Assets.xcassets in Resources */,
 				71DCDC501EAF353000BA045A /* modelist.json in Resources */,
+				426E6B291EB8720400942BE1 /* Mode.storyboard in Resources */,
 				71114AEE1EB2DEF900D2200C /* cam_scan.storyboard in Resources */,
 				71DCDC421EAF234E00BA045A /* Main.storyboard in Resources */,
 				71114AB31EB1C5C800D2200C /* LICENSE in Resources */,
@@ -389,12 +432,14 @@
 			buildActionMask = 2147483647;
 			files = (
 				71114AB21EB1C5C800D2200C /* AESCrypt.m in Sources */,
+				426E6B241EB85C2B00942BE1 /* PopModeViewController.m in Sources */,
 				71114AF01EB2DEF900D2200C /* RAMenu.m in Sources */,
 				71114AC61EB1C73B00D2200C /* ioapi.c in Sources */,
 				71114AF11EB2DEF900D2200C /* ScannerControllerView.m in Sources */,
 				71114A9D1EB1BCB400D2200C /* LoginViewController.m in Sources */,
 				71114AB51EB1C5C800D2200C /* NSData+CommonCrypto.m in Sources */,
 				71114AC71EB1C73B00D2200C /* mztools.c in Sources */,
+				426E6B271EB85C4200942BE1 /* ModelModeViewController.m in Sources */,
 				71DCDC3F1EAF234E00BA045A /* RootViewController.m in Sources */,
 				42E1B1081EB1D9B100EEF27C /* LoginSettingViewController.m in Sources */,
 				71114AC81EB1C73B00D2200C /* unzip.c in Sources */,
@@ -408,6 +453,7 @@
 				71114AA61EB1C50D00D2200C /* RAUtils.m in Sources */,
 				71DCDC3C1EAF234E00BA045A /* AppDelegate.m in Sources */,
 				42E1B1021EB1C92000EEF27C /* BasicViewController.m in Sources */,
+				426E6B1F1EB8558400942BE1 /* RootModeCell.m in Sources */,
 				71DCDC391EAF234E00BA045A /* main.m in Sources */,
 				71114ABC1EB1C73400D2200C /* ZipArchive.mm in Sources */,
 				42E1B0FE1EB1C8EE00EEF27C /* LoginTextFiledCell.m in Sources */,

BIN
RA Image/RA Image.xcodeproj/project.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 5 - 2
RA Image/RA Image/AppDelegate.h

@@ -17,12 +17,15 @@
 @property (strong,nonatomic) NSString* build;
 @property bool bLogin;
 @property (nonatomic,copy) NSString *address;
+@property (nonatomic,copy) NSString *companyName;
+@property (nonatomic,copy) UIImage *companyIcon;
+@property (nonatomic,strong) NSArray *modeList;
+@property (nonatomic,assign) BOOL shouldAutoShowModeVC;
 
 - (void)showNormalRootVC;
-
 - (void)showLoginVC;
-
 - (void)logout;
+- (void)loadCompanyIcon:(NSString *)url;
 
 @end
 

+ 17 - 0
RA Image/RA Image/AppDelegate.m

@@ -26,6 +26,7 @@
         LoginViewController *loginVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
         
         [self.window setRootViewController:loginVC];
+        self.shouldAutoShowModeVC = YES;
     }
 }
 
@@ -34,10 +35,25 @@
     self.password = nil;
     self.address = nil;
     self.bLogin = false;
+    self.companyName = nil;
+    self.companyIcon = nil;
+    self.modeList = nil;
+    [[NSNotificationCenter defaultCenter] postNotificationName:LogoutNotification object:nil];
     
     [self showLoginVC];
 }
 
+- (void)loadCompanyIcon:(NSString *)url {
+    if (!url.length) return;
+    __weak typeof(self) weakself = self;
+    dispatch_async(dispatch_get_global_queue(0, 0), ^{
+        UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];
+        if (weakself.bLogin) {
+            weakself.companyIcon = img;
+        }
+    });
+}
+
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
     // Override point for customization after application launch.
     
@@ -79,4 +95,5 @@
 }
 
 
+
 @end

+ 48 - 2
RA Image/RA Image/Base.lproj/Main.storyboard

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="zf9-JT-Kr2">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="zf9-JT-Kr2">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
         <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -37,9 +37,55 @@
                     <view key="view" contentMode="scaleToFill" id="0cG-hA-GsV">
                         <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="40" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="qOW-M6-IJk">
+                                <rect key="frame" x="0.0" y="64" width="375" height="603"/>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                <prototypes>
+                                    <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="RootModeCell" rowHeight="40" id="a3Z-Pv-WAq" customClass="RootModeCell">
+                                        <rect key="frame" x="0.0" y="28" width="375" height="40"/>
+                                        <autoresizingMask key="autoresizingMask"/>
+                                        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="a3Z-Pv-WAq" id="KU3-qN-JgJ">
+                                            <rect key="frame" x="0.0" y="0.0" width="375" height="40"/>
+                                            <autoresizingMask key="autoresizingMask"/>
+                                            <subviews>
+                                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Mode" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wdD-Sc-rpM">
+                                                    <rect key="frame" x="10" y="5" width="355" height="29.5"/>
+                                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                    <nil key="textColor"/>
+                                                    <nil key="highlightedColor"/>
+                                                </label>
+                                            </subviews>
+                                            <constraints>
+                                                <constraint firstAttribute="bottom" secondItem="wdD-Sc-rpM" secondAttribute="bottom" constant="5" id="BM5-GG-sTU"/>
+                                                <constraint firstItem="wdD-Sc-rpM" firstAttribute="top" secondItem="KU3-qN-JgJ" secondAttribute="top" constant="5" id="DDB-kZ-0Eq"/>
+                                                <constraint firstAttribute="trailing" secondItem="wdD-Sc-rpM" secondAttribute="trailing" constant="10" id="M73-FJ-0C5"/>
+                                                <constraint firstItem="wdD-Sc-rpM" firstAttribute="leading" secondItem="KU3-qN-JgJ" secondAttribute="leading" constant="10" id="zVe-cS-jj9"/>
+                                            </constraints>
+                                        </tableViewCellContentView>
+                                        <connections>
+                                            <outlet property="modeLabel" destination="wdD-Sc-rpM" id="WHN-fJ-nZN"/>
+                                        </connections>
+                                    </tableViewCell>
+                                </prototypes>
+                                <connections>
+                                    <outlet property="dataSource" destination="Dtz-oi-w09" id="jXK-hH-Zw4"/>
+                                    <outlet property="delegate" destination="Dtz-oi-w09" id="qej-WZ-udw"/>
+                                </connections>
+                            </tableView>
+                        </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                        <constraints>
+                            <constraint firstItem="X0p-Er-QSV" firstAttribute="top" secondItem="qOW-M6-IJk" secondAttribute="bottom" id="IQH-Kk-j6U"/>
+                            <constraint firstAttribute="trailing" secondItem="qOW-M6-IJk" secondAttribute="trailing" id="jxV-4b-nO7"/>
+                            <constraint firstItem="qOW-M6-IJk" firstAttribute="top" secondItem="qba-7X-gfw" secondAttribute="bottom" id="pB3-QS-V6Y"/>
+                            <constraint firstItem="qOW-M6-IJk" firstAttribute="leading" secondItem="0cG-hA-GsV" secondAttribute="leading" id="vgN-vX-TtL"/>
+                        </constraints>
                     </view>
                     <navigationItem key="navigationItem" id="OjN-Xn-Hk9"/>
+                    <connections>
+                        <outlet property="modeTable" destination="qOW-M6-IJk" id="ZxK-nd-nZ7"/>
+                    </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="okF-58-x1C" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>

+ 26 - 15
RA Image/RA Image/LoginSettingViewController.m

@@ -64,26 +64,37 @@ static NSString *kScanAddress = @"ScanAddress";
 
 - (void)scanItemClick:(UIBarButtonItem *)sender {
     
+    __weak typeof(self) weakself = self;
     ScannerViewController *scannerVC = [[UIStoryboard storyboardWithName:@"cam_scan" bundle:nil] instantiateViewControllerWithIdentifier:@"NewScannerViewController"];
     scannerVC.returnCode = ^(NSString *code) {
-        NSLog(@"code %@",code);
+        // 扫描成功保存扫描值
+        if (code.length) {
+
+            if (weakself) {
+                __strong typeof(weakself) strongself = weakself;
+//                NSString *internalAddr = @"http://192.168.0.155/wm_postgresql/handset_login.php";
+//                NSString *externalAddr = @"http://127.0.0.1";
+                
+                NSArray *dataArr = [code componentsSeparatedByString:@";"];
+                NSString *name = [dataArr objectAtIndex:0];
+                NSString *internalAddr = [dataArr objectAtIndex:1];
+                NSString *externalAddr = [dataArr objectAtIndex:2];
+                
+                
+                NSMutableDictionary *addressDic = [NSMutableDictionary dictionary];
+                [addressDic setObject:internalAddr forKey:@"internalAddress"];
+                [addressDic setObject:externalAddr forKey:@"externalAddress"];
+                strongself.nameTextField.text = name;
+                strongself.internalTextField.text = internalAddr;
+                strongself.externalTextField.text = externalAddr;
+                [strongself setUserDefaultsValue:addressDic forKey:kScanAddress];
+            }
+            
+        }
     };
     [self presentViewController:scannerVC animated:YES completion:nil];
     
-    // 扫描成功保存扫描值
-    if (true) {
-        NSString *internalAddr = @"http://192.168.0.155/wm_postgresql/handset_login.php";
-        NSString *externalAddr = @"127.0.0.1";
-        NSMutableDictionary *addressDic = [NSMutableDictionary dictionary];
-        [addressDic setObject:internalAddr forKey:@"internalAddress"];
-        [addressDic setObject:externalAddr forKey:@"externalAddress"];
-        
-        self.internalTextField.text = internalAddr;
-        self.externalTextField.text = externalAddr;
-        
-        [self setUserDefaultsValue:addressDic forKey:kScanAddress];
-        
-    }
+    
 }
 
 - (IBAction)internalCheckBtnClick:(UIButton *)sender {

+ 5 - 7
RA Image/RA Image/LoginViewController.m

@@ -103,7 +103,7 @@ static NSString *kLoginUserInfo = @"UserInfo";
     NSDictionary *itemDic = [self.dataDic objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]];
     
     NSString *type = [itemDic objectForKey:@"type"];
-    id rememberValue = [self userDefaultsValue:kRememberLogin];
+    BOOL rememberValue = [[self userDefaultsValue:kRememberLogin] boolValue];
     
     if ([type isEqualToString:@"text"]) {
         
@@ -126,11 +126,7 @@ static NSString *kLoginUserInfo = @"UserInfo";
         
         LoginSwitchCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LoginSwitchCell"];
         cell.msgLabel.text = [itemDic objectForKey:@"tip_msg"];
-        if (rememberValue) {
-            cell.stateSwitch.on = [rememberValue boolValue];
-        } else {
-            cell.stateSwitch.on = [[itemDic objectForKey:@"status"] boolValue];
-        }
+        cell.stateSwitch.on = rememberValue;
         cell.delegate = self;
         return cell;
     }
@@ -184,7 +180,9 @@ static NSString *kLoginUserInfo = @"UserInfo";
                     appDelegate.bLogin = YES;
                     appDelegate.user = strongself.user;
                     appDelegate.password = strongself.pwd;
-                    
+                    appDelegate.companyName = [loginDic objectForKey:@"company_name"];
+                    [appDelegate loadCompanyIcon:[loginDic objectForKey:@"company_icon"]];
+                    appDelegate.modeList = [loginDic objectForKey:@"modellist"];
                     [appDelegate showNormalRootVC];
                 } else {
                     NSString *msg = [loginDic objectForKey:@"err_msg"];

+ 236 - 0
RA Image/RA Image/Mode.storyboard

@@ -0,0 +1,236 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
+        <capability name="Alignment constraints to the first baseline" minToolsVersion="6.0"/>
+        <capability name="Alignment constraints with different attributes" minToolsVersion="5.1"/>
+        <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <scenes>
+        <!--Pop Mode View Controller-->
+        <scene sceneID="b6h-gy-L73">
+            <objects>
+                <viewController storyboardIdentifier="PopModeViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="K9i-vs-efO" customClass="PopModeViewController" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="dcO-dt-BeO"/>
+                        <viewControllerLayoutGuide type="bottom" id="8eX-wZ-j58"/>
+                    </layoutGuides>
+                    <view key="view" contentMode="scaleToFill" id="QEg-TT-jt8">
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tx6-Jq-V78">
+                                <rect key="frame" x="20" y="90" width="335" height="335"/>
+                                <color key="backgroundColor" red="1" green="0.36503490374616099" blue="0.7594767167726002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="335" id="0HU-zi-itA"/>
+                                    <constraint firstAttribute="width" constant="200" id="CRQ-nA-AMT"/>
+                                    <constraint firstAttribute="width" constant="335" id="g7B-l2-sh1"/>
+                                    <constraint firstAttribute="height" constant="200" id="jht-Cb-s48"/>
+                                </constraints>
+                                <variation key="default">
+                                    <mask key="constraints">
+                                        <exclude reference="0HU-zi-itA"/>
+                                        <exclude reference="CRQ-nA-AMT"/>
+                                        <exclude reference="g7B-l2-sh1"/>
+                                        <exclude reference="jht-Cb-s48"/>
+                                    </mask>
+                                </variation>
+                                <variation key="heightClass=compact-widthClass=compact">
+                                    <mask key="constraints">
+                                        <include reference="CRQ-nA-AMT"/>
+                                        <include reference="jht-Cb-s48"/>
+                                    </mask>
+                                </variation>
+                                <variation key="heightClass=regular-widthClass=compact">
+                                    <mask key="constraints">
+                                        <include reference="0HU-zi-itA"/>
+                                        <exclude reference="CRQ-nA-AMT"/>
+                                        <include reference="g7B-l2-sh1"/>
+                                        <exclude reference="jht-Cb-s48"/>
+                                    </mask>
+                                </variation>
+                            </button>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6jr-Xw-2tL">
+                                <rect key="frame" x="20" y="560" width="60" height="60"/>
+                                <color key="backgroundColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="60" id="K6W-Tz-wcn"/>
+                                </constraints>
+                                <state key="normal" title="Scan"/>
+                                <variation key="default">
+                                    <mask key="constraints">
+                                        <exclude reference="K6W-Tz-wcn"/>
+                                    </mask>
+                                </variation>
+                                <variation key="heightClass=compact-widthClass=compact">
+                                    <mask key="constraints">
+                                        <include reference="K6W-Tz-wcn"/>
+                                    </mask>
+                                </variation>
+                                <variation key="heightClass=regular-widthClass=compact">
+                                    <mask key="constraints">
+                                        <include reference="K6W-Tz-wcn"/>
+                                    </mask>
+                                </variation>
+                                <connections>
+                                    <action selector="scanBtnClick:" destination="K9i-vs-efO" eventType="touchUpInside" id="1iv-fR-oCn"/>
+                                </connections>
+                            </button>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NAz-nK-Hgz">
+                                <rect key="frame" x="157" y="560" width="60" height="60"/>
+                                <color key="backgroundColor" red="0.45257410590000002" green="1" blue="0.65812935640000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <constraints>
+                                    <constraint firstAttribute="height" constant="60" id="o6H-g4-n4a"/>
+                                </constraints>
+                                <state key="normal" title="Camera"/>
+                                <connections>
+                                    <action selector="cameraBtnClick:" destination="K9i-vs-efO" eventType="touchUpInside" id="h3G-rL-P7U"/>
+                                </connections>
+                            </button>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="PIID:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7rM-i2-eHr">
+                                <rect key="frame" x="20" y="454" width="335" height="21"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jte-R6-noU">
+                                <rect key="frame" x="295" y="560" width="60" height="60"/>
+                                <color key="backgroundColor" red="0.25435081980000002" green="0.75957768849999996" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <state key="normal" title="Upload"/>
+                                <connections>
+                                    <action selector="uploadBtnClick:" destination="K9i-vs-efO" eventType="touchUpInside" id="raC-cp-9OQ"/>
+                                </connections>
+                            </button>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                        <constraints>
+                            <constraint firstItem="7rM-i2-eHr" firstAttribute="bottom" secondItem="tx6-Jq-V78" secondAttribute="bottom" constant="50" id="5oU-RN-aAR"/>
+                            <constraint firstItem="tx6-Jq-V78" firstAttribute="top" secondItem="dcO-dt-BeO" secondAttribute="bottom" constant="70" id="5rw-rk-Rgm"/>
+                            <constraint firstItem="NAz-nK-Hgz" firstAttribute="leading" secondItem="6jr-Xw-2tL" secondAttribute="trailing" constant="50" id="6V1-Ef-pvP"/>
+                            <constraint firstItem="NAz-nK-Hgz" firstAttribute="top" secondItem="6jr-Xw-2tL" secondAttribute="top" id="Azo-Ej-bva"/>
+                            <constraint firstItem="jte-R6-noU" firstAttribute="height" secondItem="NAz-nK-Hgz" secondAttribute="height" id="Cz1-jn-gUG"/>
+                            <constraint firstItem="jte-R6-noU" firstAttribute="width" secondItem="NAz-nK-Hgz" secondAttribute="width" id="G9A-SK-NbZ"/>
+                            <constraint firstItem="7rM-i2-eHr" firstAttribute="leading" secondItem="6jr-Xw-2tL" secondAttribute="leading" id="Ga1-pH-f1Y"/>
+                            <constraint firstItem="NAz-nK-Hgz" firstAttribute="width" secondItem="6jr-Xw-2tL" secondAttribute="width" id="Hu1-eO-C70"/>
+                            <constraint firstItem="NAz-nK-Hgz" firstAttribute="bottom" secondItem="6jr-Xw-2tL" secondAttribute="bottom" id="IEC-xA-RER"/>
+                            <constraint firstItem="7rM-i2-eHr" firstAttribute="leading" secondItem="tx6-Jq-V78" secondAttribute="leading" id="IkZ-kb-uSH"/>
+                            <constraint firstItem="7rM-i2-eHr" firstAttribute="width" secondItem="tx6-Jq-V78" secondAttribute="width" id="KLA-9l-yX3"/>
+                            <constraint firstItem="tx6-Jq-V78" firstAttribute="centerY" secondItem="QEg-TT-jt8" secondAttribute="centerY" id="PVr-4c-8If"/>
+                            <constraint firstItem="6jr-Xw-2tL" firstAttribute="leading" secondItem="tx6-Jq-V78" secondAttribute="trailing" constant="60" id="PaT-5f-5BR"/>
+                            <constraint firstItem="tx6-Jq-V78" firstAttribute="top" secondItem="dcO-dt-BeO" secondAttribute="bottom" constant="70" id="Q50-Zd-pg5"/>
+                            <constraint firstItem="tx6-Jq-V78" firstAttribute="leading" secondItem="QEg-TT-jt8" secondAttribute="leadingMargin" constant="30" id="T4x-ql-gYS"/>
+                            <constraint firstItem="8eX-wZ-j58" firstAttribute="top" secondItem="NAz-nK-Hgz" secondAttribute="bottom" constant="47" id="UFG-NX-fXs"/>
+                            <constraint firstItem="jte-R6-noU" firstAttribute="leading" secondItem="NAz-nK-Hgz" secondAttribute="trailing" constant="50" id="X0n-8i-crf"/>
+                            <constraint firstItem="jte-R6-noU" firstAttribute="trailing" secondItem="tx6-Jq-V78" secondAttribute="trailing" id="aEa-b6-mFx"/>
+                            <constraint firstAttribute="trailingMargin" secondItem="7rM-i2-eHr" secondAttribute="trailing" id="aWv-n7-eAS"/>
+                            <constraint firstItem="jte-R6-noU" firstAttribute="bottom" secondItem="NAz-nK-Hgz" secondAttribute="bottom" id="bYg-yw-F3b"/>
+                            <constraint firstItem="6jr-Xw-2tL" firstAttribute="leading" secondItem="7rM-i2-eHr" secondAttribute="leading" id="dXd-PM-PHl"/>
+                            <constraint firstItem="jte-R6-noU" firstAttribute="height" secondItem="NAz-nK-Hgz" secondAttribute="height" id="fPr-5K-jIw"/>
+                            <constraint firstItem="NAz-nK-Hgz" firstAttribute="centerX" secondItem="QEg-TT-jt8" secondAttribute="centerX" id="fWf-CG-Oxq"/>
+                            <constraint firstItem="6jr-Xw-2tL" firstAttribute="bottom" secondItem="tx6-Jq-V78" secondAttribute="bottom" id="gKZ-Rf-rrp"/>
+                            <constraint firstItem="NAz-nK-Hgz" firstAttribute="baseline" secondItem="jte-R6-noU" secondAttribute="baseline" id="iGI-ja-RL9"/>
+                            <constraint firstItem="NAz-nK-Hgz" firstAttribute="baseline" secondItem="6jr-Xw-2tL" secondAttribute="firstBaseline" id="jQL-1o-us5"/>
+                            <constraint firstItem="NAz-nK-Hgz" firstAttribute="width" secondItem="6jr-Xw-2tL" secondAttribute="width" id="nDa-Fe-yJJ"/>
+                            <constraint firstItem="NAz-nK-Hgz" firstAttribute="firstBaseline" secondItem="6jr-Xw-2tL" secondAttribute="baseline" id="pNG-k3-IPR"/>
+                            <constraint firstItem="7rM-i2-eHr" firstAttribute="top" secondItem="tx6-Jq-V78" secondAttribute="top" id="sxc-Kf-lRS"/>
+                            <constraint firstItem="jte-R6-noU" firstAttribute="width" secondItem="NAz-nK-Hgz" secondAttribute="width" id="xNj-Z3-CKd"/>
+                            <constraint firstItem="tx6-Jq-V78" firstAttribute="centerX" secondItem="QEg-TT-jt8" secondAttribute="centerX" id="xWS-0a-saS"/>
+                            <constraint firstItem="NAz-nK-Hgz" firstAttribute="height" secondItem="6jr-Xw-2tL" secondAttribute="height" id="zU9-uo-KR5"/>
+                        </constraints>
+                        <variation key="default">
+                            <mask key="constraints">
+                                <exclude reference="5rw-rk-Rgm"/>
+                                <exclude reference="PVr-4c-8If"/>
+                                <exclude reference="Q50-Zd-pg5"/>
+                                <exclude reference="T4x-ql-gYS"/>
+                                <exclude reference="xWS-0a-saS"/>
+                                <exclude reference="5oU-RN-aAR"/>
+                                <exclude reference="Ga1-pH-f1Y"/>
+                                <exclude reference="IkZ-kb-uSH"/>
+                                <exclude reference="KLA-9l-yX3"/>
+                                <exclude reference="aWv-n7-eAS"/>
+                                <exclude reference="sxc-Kf-lRS"/>
+                                <exclude reference="PaT-5f-5BR"/>
+                                <exclude reference="dXd-PM-PHl"/>
+                                <exclude reference="gKZ-Rf-rrp"/>
+                                <exclude reference="6V1-Ef-pvP"/>
+                                <exclude reference="Azo-Ej-bva"/>
+                                <exclude reference="Hu1-eO-C70"/>
+                                <exclude reference="IEC-xA-RER"/>
+                                <exclude reference="fWf-CG-Oxq"/>
+                                <exclude reference="iGI-ja-RL9"/>
+                                <exclude reference="jQL-1o-us5"/>
+                                <exclude reference="nDa-Fe-yJJ"/>
+                                <exclude reference="pNG-k3-IPR"/>
+                                <exclude reference="zU9-uo-KR5"/>
+                                <exclude reference="Cz1-jn-gUG"/>
+                                <exclude reference="G9A-SK-NbZ"/>
+                                <exclude reference="X0n-8i-crf"/>
+                                <exclude reference="aEa-b6-mFx"/>
+                                <exclude reference="bYg-yw-F3b"/>
+                                <exclude reference="fPr-5K-jIw"/>
+                                <exclude reference="xNj-Z3-CKd"/>
+                                <exclude reference="UFG-NX-fXs"/>
+                            </mask>
+                        </variation>
+                        <variation key="heightClass=compact-widthClass=compact">
+                            <mask key="constraints">
+                                <include reference="PVr-4c-8If"/>
+                                <include reference="T4x-ql-gYS"/>
+                                <include reference="Ga1-pH-f1Y"/>
+                                <include reference="aWv-n7-eAS"/>
+                                <include reference="sxc-Kf-lRS"/>
+                                <include reference="PaT-5f-5BR"/>
+                                <include reference="gKZ-Rf-rrp"/>
+                                <include reference="6V1-Ef-pvP"/>
+                                <include reference="Hu1-eO-C70"/>
+                                <include reference="IEC-xA-RER"/>
+                                <include reference="zU9-uo-KR5"/>
+                                <include reference="Cz1-jn-gUG"/>
+                                <include reference="G9A-SK-NbZ"/>
+                                <include reference="X0n-8i-crf"/>
+                                <include reference="bYg-yw-F3b"/>
+                            </mask>
+                        </variation>
+                        <variation key="heightClass=regular-widthClass=compact">
+                            <mask key="constraints">
+                                <include reference="5rw-rk-Rgm"/>
+                                <include reference="Q50-Zd-pg5"/>
+                                <include reference="xWS-0a-saS"/>
+                                <include reference="5oU-RN-aAR"/>
+                                <include reference="IkZ-kb-uSH"/>
+                                <include reference="KLA-9l-yX3"/>
+                                <include reference="dXd-PM-PHl"/>
+                                <include reference="Azo-Ej-bva"/>
+                                <include reference="fWf-CG-Oxq"/>
+                                <include reference="iGI-ja-RL9"/>
+                                <include reference="jQL-1o-us5"/>
+                                <include reference="nDa-Fe-yJJ"/>
+                                <include reference="pNG-k3-IPR"/>
+                                <include reference="aEa-b6-mFx"/>
+                                <include reference="fPr-5K-jIw"/>
+                                <include reference="xNj-Z3-CKd"/>
+                                <include reference="UFG-NX-fXs"/>
+                            </mask>
+                        </variation>
+                    </view>
+                    <connections>
+                        <outlet property="barcodeLabel" destination="7rM-i2-eHr" id="aB2-mx-aAt"/>
+                        <outlet property="camerBtn" destination="NAz-nK-Hgz" id="5L3-aN-Dtb"/>
+                        <outlet property="imgBtn" destination="tx6-Jq-V78" id="xle-Dc-8GI"/>
+                        <outlet property="scanBtn" destination="6jr-Xw-2tL" id="ciK-Vz-r3k"/>
+                        <outlet property="uploadBtn" destination="jte-R6-noU" id="aQd-uP-dmR"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="GQR-ak-uz6" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="-250.40000000000001" y="105.69715142428787"/>
+        </scene>
+    </scenes>
+</document>

+ 13 - 0
RA Image/RA Image/ModelModeViewController.h

@@ -0,0 +1,13 @@
+//
+//  ModelModeViewController.h
+//  RA Image
+//
+//  Created by Jack on 2017/5/2.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "BasicViewController.h"
+
+@interface ModelModeViewController : BasicViewController
+
+@end

+ 29 - 0
RA Image/RA Image/ModelModeViewController.m

@@ -0,0 +1,29 @@
+//
+//  ModelModeViewController.m
+//  RA Image
+//
+//  Created by Jack on 2017/5/2.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "ModelModeViewController.h"
+
+@interface ModelModeViewController ()
+
+@end
+
+@implementation ModelModeViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    self.view.backgroundColor = [UIColor blueColor];
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+
+@end

+ 15 - 0
RA Image/RA Image/PopModeViewController.h

@@ -0,0 +1,15 @@
+//
+//  PopModeViewController.h
+//  RA Image
+//
+//  Created by Jack on 2017/5/2.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "BasicViewController.h"
+
+@interface PopModeViewController : BasicViewController
+
+
+
+@end

+ 50 - 0
RA Image/RA Image/PopModeViewController.m

@@ -0,0 +1,50 @@
+//
+//  PopModeViewController.m
+//  RA Image
+//
+//  Created by Jack on 2017/5/2.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "PopModeViewController.h"
+
+@interface PopModeViewController ()
+@property (strong, nonatomic) IBOutlet UIButton *scanBtn;
+@property (strong, nonatomic) IBOutlet UIButton *camerBtn;
+@property (strong, nonatomic) IBOutlet UIButton *uploadBtn;
+@property (strong, nonatomic) IBOutlet UIButton *imgBtn;
+@property (strong, nonatomic) IBOutlet UILabel *barcodeLabel;
+
+@end
+
+@implementation PopModeViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+
+}
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+#pragma mark - Button Action
+
+- (IBAction)scanBtnClick:(UIButton *)sender {
+    NSLog(@"%s",__FUNCTION__);
+    self.barcodeLabel.text = @"scan";
+}
+
+- (IBAction)cameraBtnClick:(UIButton *)sender {
+    NSLog(@"%s",__FUNCTION__);
+    self.barcodeLabel.text = @"camera";
+}
+
+- (IBAction)uploadBtnClick:(UIButton *)sender {
+    NSLog(@"%s",__FUNCTION__);
+    self.barcodeLabel.text = @"upload";
+}
+
+@end

+ 15 - 0
RA Image/RA Image/RootModeCell.h

@@ -0,0 +1,15 @@
+//
+//  RootModeCell.h
+//  RA Image
+//
+//  Created by Jack on 2017/5/2.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface RootModeCell : UITableViewCell
+
+@property (nonatomic,copy) NSString *mode;
+
+@end

+ 34 - 0
RA Image/RA Image/RootModeCell.m

@@ -0,0 +1,34 @@
+//
+//  RootModeCell.m
+//  RA Image
+//
+//  Created by Jack on 2017/5/2.
+//  Copyright © 2017年 USAI. All rights reserved.
+//
+
+#import "RootModeCell.h"
+
+@interface RootModeCell ()
+@property (strong, nonatomic) IBOutlet UILabel *modeLabel;
+
+@end
+
+@implementation RootModeCell
+
+- (void)awakeFromNib {
+    [super awakeFromNib];
+    // Initialization code
+}
+
+- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
+    [super setSelected:selected animated:animated];
+
+    // Configure the view for the selected state
+}
+
+- (void)setMode:(NSString *)mode {
+    _mode = mode;
+    self.modeLabel.text = mode;
+}
+
+@end

+ 90 - 3
RA Image/RA Image/RootViewController.m

@@ -8,8 +8,19 @@
 
 #import "RootViewController.h"
 #import "LoginViewController.h"
+#import "RootModeCell.h"
+#import "PopModeViewController.h"
+#import "ModelModeViewController.h"
+
+static NSString *kLastMode = @"lastChooseMode";
+
+@interface RootViewController ()<UITableViewDelegate,UITableViewDataSource>
+
+@property (strong, nonatomic) IBOutlet UITableView *modeTable;
+@property (nonatomic,strong) NSArray *modeList;
+@property (nonatomic,assign) NSInteger lastChoosedIndex;
+
 
-@interface RootViewController ()
 
 @end
 
@@ -18,14 +29,21 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     // Do any additional setup after loading the view, typically from a nib.
-    
+    UIView *v = [UIView new];
+    [self.view insertSubview:v atIndex:0];
+    self.lastChoosedIndex = -1;
+
     self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStylePlain target:self action:@selector(logoutItemClick:)];
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    self.title = appDelegate.companyName;
+    self.modeList = appDelegate.modeList;
+    self.modeTable.tableFooterView = [UIView new];
 }
 
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
     
-    
+    [self.modeTable reloadData];
 }
 
 
@@ -58,5 +76,74 @@
 
 }
 
+- (void)viewDidAppear:(BOOL)animated {
+    [super viewDidAppear:animated];
+    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+    if (appDelegate.shouldAutoShowModeVC) {
+        if (self.lastChoosedIndex > -1) {
+            NSDictionary *mode = [self.modeList objectAtIndex:self.lastChoosedIndex];
+            NSString *name = [mode objectForKey:@"name"];
+            [self pushCurrentModeController:name];
+        }
+        
+        appDelegate.shouldAutoShowModeVC = NO;
+    }
+}
+
+#pragma mark - DataSource
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    return self.modeList.count;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    
+    RootModeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RootModeCell"];
+    NSDictionary *mode = [self.modeList objectAtIndex:indexPath.row];
+    NSString *name = [mode objectForKey:@"name"];
+    cell.mode = name;
+    NSString *lastChoosedMode = [self userDefaultsValue:kLastMode];
+    if (lastChoosedMode.length) {
+        if ([lastChoosedMode isEqualToString:name]) {
+            self.lastChoosedIndex = indexPath.row;
+        }
+    }
+    
+    return cell;
+}
+
+#pragma mark - Delegate
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    RootModeCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+    NSString *mode = cell.mode;
+    [self setUserDefaultsValue:mode forKey:kLastMode];
+    [self pushCurrentModeController:mode];
+}
+
+#pragma mark - Private
+
+- (void)pushCurrentModeController:(NSString *)mode {
+    BasicViewController *modeVC = nil;
+    if ([mode isEqualToString:@"Model"]) {
+        ModelModeViewController *vc = [[ModelModeViewController alloc] init];
+        modeVC = vc;
+    }else if ([mode isEqualToString:@"POP"]) {
+        PopModeViewController *vc = [[UIStoryboard storyboardWithName:@"Mode" bundle:nil] instantiateViewControllerWithIdentifier:@"PopModeViewController"];
+        modeVC = vc;
+    }
+    
+    if (modeVC) {
+        [self.navigationController pushViewController:modeVC animated:YES];
+    }
+    
+}
+
+- (void)userLogout:(NSNotification *)notification {
+    
+    [self.modeTable reloadData];
+    [super userLogout:notification];
+}
+
 
 @end