diff --git a/prototype.xcodeproj/project.pbxproj b/prototype.xcodeproj/project.pbxproj index 4ca45b8..a0b982c 100755 --- a/prototype.xcodeproj/project.pbxproj +++ b/prototype.xcodeproj/project.pbxproj @@ -13,8 +13,9 @@ DAEDDA5219AE207C007E68AE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DAEDDA5019AE207C007E68AE /* Main.storyboard */; }; DAEDDA5419AE207C007E68AE /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DAEDDA5319AE207C007E68AE /* Images.xcassets */; }; DAEDDA6019AE207C007E68AE /* prototypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEDDA5F19AE207C007E68AE /* prototypeTests.swift */; }; + F86E53C819BF30CA009086FD /* mainNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F86E53C719BF30CA009086FD /* mainNavigationController.swift */; }; F883147219BC34B10051BC38 /* settingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F883147119BC34B10051BC38 /* settingViewController.swift */; }; - F883147619BC44620051BC38 /* initViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F883147519BC44620051BC38 /* initViewController.swift */; }; + F883147619BC44620051BC38 /* loginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F883147519BC44620051BC38 /* loginViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -38,8 +39,9 @@ DAEDDA5919AE207C007E68AE /* prototypeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = prototypeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; DAEDDA5E19AE207C007E68AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; DAEDDA5F19AE207C007E68AE /* prototypeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = prototypeTests.swift; sourceTree = ""; }; + F86E53C719BF30CA009086FD /* mainNavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = mainNavigationController.swift; sourceTree = ""; }; F883147119BC34B10051BC38 /* settingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = settingViewController.swift; sourceTree = ""; }; - F883147519BC44620051BC38 /* initViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = initViewController.swift; sourceTree = ""; }; + F883147519BC44620051BC38 /* loginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = loginViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -82,14 +84,15 @@ isa = PBXGroup; children = ( DAEDDA6919AE27F6007E68AE /* images */, + DAAFC34519B4BBF80074C7F9 /* LineViewController.swift */, F883147119BC34B10051BC38 /* settingViewController.swift */, DAEDDA4C19AE207B007E68AE /* AppDelegate.swift */, DAEDDA4E19AE207C007E68AE /* ViewController.swift */, DAEDDA5019AE207C007E68AE /* Main.storyboard */, - F883147519BC44620051BC38 /* initViewController.swift */, + F86E53C719BF30CA009086FD /* mainNavigationController.swift */, + F883147519BC44620051BC38 /* loginViewController.swift */, DAEDDA5319AE207C007E68AE /* Images.xcassets */, DAEDDA4A19AE207B007E68AE /* Supporting Files */, - DAAFC34519B4BBF80074C7F9 /* LineViewController.swift */, ); path = prototype; sourceTree = ""; @@ -225,11 +228,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - F883147619BC44620051BC38 /* initViewController.swift in Sources */, + F883147619BC44620051BC38 /* loginViewController.swift in Sources */, DAEDDA4F19AE207C007E68AE /* ViewController.swift in Sources */, DAEDDA4D19AE207B007E68AE /* AppDelegate.swift in Sources */, DAAFC34619B4BBF80074C7F9 /* LineViewController.swift in Sources */, F883147219BC34B10051BC38 /* settingViewController.swift in Sources */, + F86E53C819BF30CA009086FD /* mainNavigationController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/prototype.xcodeproj/project.xcworkspace/xcuserdata/Star.xcuserdatad/UserInterfaceState.xcuserstate b/prototype.xcodeproj/project.xcworkspace/xcuserdata/Star.xcuserdatad/UserInterfaceState.xcuserstate index c9e4329..cabb1ec 100644 Binary files a/prototype.xcodeproj/project.xcworkspace/xcuserdata/Star.xcuserdatad/UserInterfaceState.xcuserstate and b/prototype.xcodeproj/project.xcworkspace/xcuserdata/Star.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/prototype.xcodeproj/project.xcworkspace/xcuserdata/Star.xcuserdatad/WorkspaceSettings.xcsettings b/prototype.xcodeproj/project.xcworkspace/xcuserdata/Star.xcuserdatad/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..1d588ff --- /dev/null +++ b/prototype.xcodeproj/project.xcworkspace/xcuserdata/Star.xcuserdatad/WorkspaceSettings.xcsettings @@ -0,0 +1,20 @@ + + + + + BuildLocationStyle + UseAppPreferences + CustomBuildLocationType + RelativeToDerivedData + DerivedDataLocationStyle + Default + IssueFilterStyle + ShowActiveSchemeOnly + LiveSourceIssuesEnabled + + SnapshotAutomaticallyBeforeSignificantChanges + + SnapshotLocationStyle + Default + + diff --git a/prototype.xcodeproj/xcuserdata/Star.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/prototype.xcodeproj/xcuserdata/Star.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 5654def..094d897 100644 --- a/prototype.xcodeproj/xcuserdata/Star.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/prototype.xcodeproj/xcuserdata/Star.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -38,45 +38,43 @@ + startingLineNumber = "9" + endingLineNumber = "9"> + startingLineNumber = "11" + endingLineNumber = "11" + offsetFromSymbolStart = "26"> + startingLineNumber = "11" + endingLineNumber = "11" + offsetFromSymbolStart = "4"> @@ -87,13 +85,45 @@ shouldBeEnabled = "No" ignoreCount = "0" continueAfterRunningActions = "No" - filePath = "prototype/settingViewController.swift" - timestampString = "431769881.261007" + filePath = "prototype/loginViewController.swift" + timestampString = "432204499.232427" + startingColumnNumber = "9223372036854775807" + endingColumnNumber = "9223372036854775807" + startingLineNumber = "56" + endingLineNumber = "56" + landmarkName = "login(_:)" + landmarkType = "5"> + + + + + + + + diff --git a/prototype/Base.lproj/Main.storyboard b/prototype/Base.lproj/Main.storyboard index 45553a4..bfc7ee6 100755 --- a/prototype/Base.lproj/Main.storyboard +++ b/prototype/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -7,47 +7,55 @@ - + + + + + - @@ -65,36 +73,40 @@ - - - + + + + + - + + + + + - + - - - - + - @@ -124,12 +134,16 @@ - + + + + + @@ -139,7 +153,7 @@ - + @@ -159,49 +173,58 @@ - + + + + + - + - - + - - - + - + + + + - + @@ -212,7 +235,7 @@ - + @@ -234,8 +257,8 @@ - - + + @@ -243,25 +266,26 @@ - + - + - + + - + - + diff --git a/prototype/Info.plist b/prototype/Info.plist index ee65448..3a51372 100755 --- a/prototype/Info.plist +++ b/prototype/Info.plist @@ -31,6 +31,8 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad diff --git a/prototype/initViewController.swift b/prototype/initViewController.swift deleted file mode 100644 index 83416d4..0000000 --- a/prototype/initViewController.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// initViewController.swift -// prototype -// -// Created by Star on 14-9-7. -// Copyright (c) 2014年 langcaiye. All rights reserved. -// - -import UIKit - -class initViewController: UIViewController { - - - override func viewDidLoad() { - super.viewDidLoad() - - // Do any additional setup after loading the view. - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - - /* - // #pragma mark - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepareForSegue(segue: UIStoryboardSegue?, sender: AnyObject?) { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. - } - */ - -} diff --git a/prototype/loginViewController.swift b/prototype/loginViewController.swift new file mode 100644 index 0000000..12b90f8 --- /dev/null +++ b/prototype/loginViewController.swift @@ -0,0 +1,76 @@ +// +// initViewController.swift +// prototype +// +// Created by Star on 14-9-7. +// Copyright (c) 2014年 langcaiye. All rights reserved. +// + +import UIKit + +class loginViewController: UIViewController { + + + @IBOutlet var loginName : UITextField + @IBOutlet var loginSecr : UITextField + @IBOutlet var loginBTN : UIButton + + init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + // Custom initialization + } + + init(coder aDecoder: NSCoder!) { + super.init(coder:aDecoder) + } + + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + + loginBTN.addTarget(self,action:"login:",forControlEvents:UIControlEvents.TouchDown) + + } + + func login(sender: UIButton){ + + let content = "UserName:" + loginName.text + ";UserSecret:" + loginSecr.text + println(content) + let contenDate = content.dataUsingEncoding(NSUTF8StringEncoding) + + var path:NSString=NSHomeDirectory(); + var fileName:NSString="/lc.txt" //login crendential + path=path.stringByAppendingString(fileName) +// println(path); + + var file=NSFileManager() + if ( !file.fileExistsAtPath(path)) { + file.createFileAtPath(path,contents:contenDate,attributes:nil) + println("create file") + } + else{ + println("file existing") + var str:NSString = NSString.stringWithContentsOfFile(path,encoding:NSUTF8StringEncoding,error:nil) + println(str) + } + + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // #pragma mark - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepareForSegue(segue: UIStoryboardSegue?, sender: AnyObject?) { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/prototype/mainNavigationController.swift b/prototype/mainNavigationController.swift new file mode 100644 index 0000000..03d86bc --- /dev/null +++ b/prototype/mainNavigationController.swift @@ -0,0 +1,80 @@ +// +// mainViewController.swift +// prototype +// +// Created by Star on 14-9-9. +// Copyright (c) 2014年 langcaiye. All rights reserved. +// + +import UIKit + +class mainNavigationController: UINavigationController { + + + override func viewDidLoad() { + super.viewDidLoad() + + var btnOut:UIButton = UIButton.buttonWithType(UIButtonType.System)as UIButton + btnOut.frame = CGRectMake(0,320,320,30) + btnOut.setTitle("Log Out",forState:UIControlState.Normal) + btnOut.addTarget(self,action:"logout:",forControlEvents:UIControlEvents.TouchDown) + self.view.addSubview(btnOut) + + } + + override func viewDidAppear(animated: Bool){ + testLogin() + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + //to auto-login-in + func testLogin(){ + var path:NSString=NSHomeDirectory(); + var fileName:NSString="/lc.txt" //login crendential + path=path.stringByAppendingString(fileName) + // println(path); + + var file=NSFileManager() + if ( !file.fileExistsAtPath(path)) { + println("file not existing") + + var sty = UIStoryboard(name: "Main",bundle: nil) + var loginVC:UIViewController = sty.instantiateViewControllerWithIdentifier("loginView") as UIViewController + + self.presentViewController(loginVC,animated: true,completion:nil) + println("show login interface") + } + else{ + println("file existing") + var str:NSString = NSString.stringWithContentsOfFile(path,encoding:NSUTF8StringEncoding,error:nil) + println(str) + } + } + + + func logout(sender: UIButton){ + var file=NSFileManager() + var path=NSHomeDirectory(); + var fileName:NSString="/lc.txt" //login crendential + path=path.stringByAppendingString(fileName) + file.removeItemAtPath(path,error:nil) + println("file deleted") + + testLogin() + } + + /* + // #pragma mark - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepareForSegue(segue: UIStoryboardSegue?, sender: AnyObject?) { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/prototype/settingViewController.swift b/prototype/settingViewController.swift index eaf08f0..ffb9301 100644 --- a/prototype/settingViewController.swift +++ b/prototype/settingViewController.swift @@ -9,20 +9,40 @@ import UIKit class settingViewController: UIViewController { + @IBOutlet var doneBTN : UIButton override func viewDidLoad() { super.viewDidLoad() //button for submit all settings and return. - var btnDone:UIButton = UIButton.buttonWithType(UIButtonType.System)as UIButton - btnDone.frame = CGRectMake(0,320,320,30) - btnDone.setTitle("完成",forState:UIControlState.Normal) - btnDone.addTarget(self,action:"settingDone:",forControlEvents:UIControlEvents.TouchDown) - self.view.addSubview(btnDone) + doneBTN.addTarget(self,action:"settingDone:",forControlEvents:UIControlEvents.TouchDown) } //func to return to the first screen func settingDone(sender: UIButton){ - self.presentingViewController.presentingViewController.dismissModalViewControllerAnimated(true) + + let content = "UserName:a;UserSecret:c" + println(content) + let contenDate = content.dataUsingEncoding(NSUTF8StringEncoding) + + var path:NSString=NSHomeDirectory(); + var fileName:NSString="/lc.txt" //login crendential + path=path.stringByAppendingString(fileName) + // println(path); + + var file=NSFileManager() + if ( !file.fileExistsAtPath(path)) { + file.createFileAtPath(path,contents:contenDate,attributes:nil) + println("create file") + } + else{ + println("file existing") + var str:NSString = NSString.stringWithContentsOfFile(path,encoding:NSUTF8StringEncoding,error:nil) + println(str) + } + + + self.presentingViewController.presentingViewController.presentingViewController.dismissViewControllerAnimated(true,nil) + } override func didReceiveMemoryWarning() {