| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 56679b7 commit a1ec93d
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,6 +120,7 @@ | |||
| 120 | 120 | 4E217F171A70EDC700F6DF88 /* SVWebViewControllerActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E217F0B1A70EDC700F6DF88 /* SVWebViewControllerActivity.m */; }; | |
| 121 | 121 | 4E217F1A1A71007800F6DF88 /* SVWebViewController.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4E217F1C1A71007800F6DF88 /* SVWebViewController.strings */; }; | |
| 122 | 122 | 4E24B2681B43D33F004D7989 /* ProjectToChooseListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E24B2671B43D33F004D7989 /* ProjectToChooseListViewController.m */; }; | |
| 123 | + 4E25271A1C327FAE0032A7F4 /* UIViewController+BackButtonHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E2527191C327FAE0032A7F4 /* UIViewController+BackButtonHandler.m */; }; | ||
| 123 | 124 | 4E2719B81AB02F31006AE214 /* NProjectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E2719B71AB02F31006AE214 /* NProjectViewController.m */; }; | |
| 124 | 125 | 4E2719C71AB07ED6006AE214 /* dot_line@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E2719C61AB07ED6006AE214 /* dot_line@2x.png */; }; | |
| 125 | 126 | 4E2906A21A403B7D008A5B97 /* FileDownloadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E2906A11A403B7D008A5B97 /* FileDownloadView.m */; }; | |
@@ -1205,6 +1206,8 @@ | |||
| 1205 | 1206 | 4E217F1D1A71007C00F6DF88 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/SVWebViewController.strings"; sourceTree = "<group>"; }; | |
| 1206 | 1207 | 4E24B2661B43D33F004D7989 /* ProjectToChooseListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectToChooseListViewController.h; sourceTree = "<group>"; }; | |
| 1207 | 1208 | 4E24B2671B43D33F004D7989 /* ProjectToChooseListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectToChooseListViewController.m; sourceTree = "<group>"; }; | |
| 1209 | + 4E2527181C327FAE0032A7F4 /* UIViewController+BackButtonHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+BackButtonHandler.h"; sourceTree = "<group>"; }; | ||
| 1210 | + 4E2527191C327FAE0032A7F4 /* UIViewController+BackButtonHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+BackButtonHandler.m"; sourceTree = "<group>"; }; | ||
| 1208 | 1211 | 4E2719B61AB02F31006AE214 /* NProjectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NProjectViewController.h; sourceTree = "<group>"; }; | |
| 1209 | 1212 | 4E2719B71AB02F31006AE214 /* NProjectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NProjectViewController.m; sourceTree = "<group>"; }; | |
| 1210 | 1213 | 4E2719C61AB07ED6006AE214 /* dot_line@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "dot_line@2x.png"; sourceTree = "<group>"; }; | |
@@ -3517,6 +3520,8 @@ | |||
| 3517 | 3520 | 4E0BD8551B6C7DFD0061CAA6 /* UIView+Frame.m */, | |
| 3518 | 3521 | D09AA5BE1BFDEDD1008CA9EB /* NSString+Attribute.h */, | |
| 3519 | 3522 | D09AA5BF1BFDEDD1008CA9EB /* NSString+Attribute.m */, | |
| 3523 | + 4E2527181C327FAE0032A7F4 /* UIViewController+BackButtonHandler.h */, | ||
| 3524 | + 4E2527191C327FAE0032A7F4 /* UIViewController+BackButtonHandler.m */, | ||
| 3520 | 3525 | ); | |
| 3521 | 3526 | path = OC_Category; | |
| 3522 | 3527 | sourceTree = "<group>"; | |
@@ -5917,6 +5922,7 @@ | |||
| 5917 | 5922 | 4EABD2541AD3CA7E005E515F /* UIMessageInputView.m in Sources */, | |
| 5918 | 5923 | 7EB02FE61B6D0F3E00D2166C /* AudioManager.m in Sources */, | |
| 5919 | 5924 | 4E72F82D1B144778001B6CE6 /* NSMutableString+Common.m in Sources */, | |
| 5925 | + 4E25271A1C327FAE0032A7F4 /* UIViewController+BackButtonHandler.m in Sources */, | ||
| 5920 | 5926 | 4E4D6A791B1C6C7800FD2E49 /* MRPRDetailCell.m in Sources */, | |
| 5921 | 5927 | 8EF643CA19FF7E2900F7EEB0 /* TopicContentCell.m in Sources */, | |
| 5922 | 5928 | 4E0B9A371BAD377600D57D54 /* ForkTreeCell.m in Sources */, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,7 @@ | |||
| 16 | 16 | #import "WebViewController.h" | |
| 17 | 17 | #import "CannotLoginViewController.h" | |
| 18 | 18 | #import "EaseInputTipsView.h" | |
| 19 | + #import "UIViewController+BackButtonHandler.h" | ||
| 19 | 20 | ||
| 20 | 21 | @interface RegisterViewController ()<UITableViewDataSource, UITableViewDelegate, TTTAttributedLabelDelegate> | |
| 21 | 22 | @property (nonatomic, assign) RegisterMethodType medthodType; | |
@@ -73,9 +74,21 @@ - (void)viewDidLoad | |||
| 73 | 74 | self.myTableView.tableFooterView=[self customFooterView]; | |
| 74 | 75 | [self configTopView]; | |
| 75 | 76 | [self configBottomView]; | |
| 77 | + } | ||
| 76 | 78 | ||
| 79 | + - (BOOL)navigationShouldPopOnBackButton{ | ||
| 80 | + if (_medthodType == RegisterMethodPhone && _stepIndex >= 2 && _myRegister.password.length > 0) {//顺序来到的第二步,不允许直接返回 | ||
| 81 | + [[UIActionSheet bk_actionSheetCustomWithTitle:@"完成激活后才能正常使用 Coding,是否返回?" buttonTitles:nil destructiveTitle:@"确认返回" cancelTitle:@"取消" andDidDismissBlock:^(UIActionSheet *sheet, NSInteger index) { | ||
| 82 | + if (index == 0) { | ||
| 83 | + [self.navigationController popViewControllerAnimated:YES]; | ||
| 84 | + } | ||
| 85 | + }] showInView:self.view]; | ||
| 86 | + return NO; | ||
| 87 | + } | ||
| 88 | + return YES; | ||
| 77 | 89 | } | |
| 78 | 90 | ||
| 91 | + | ||
| 79 | 92 | - (void)refreshCaptchaNeeded{ | |
| 80 | 93 | __weak typeof(self) weakSelf = self; | |
| 81 | 94 | [[Coding_NetAPIManager sharedManager] request_CaptchaNeededWithPath:@"api/captcha/register" andBlock:^(id data, NSError *error) { | |
@@ -95,11 +108,15 @@ - (void)viewWillAppear:(BOOL)animated{ | |||
| 95 | 108 | if (_medthodType == RegisterMethodEamil || _stepIndex == 1) { | |
| 96 | 109 | [self refreshCaptchaNeeded]; | |
| 97 | 110 | } | |
| 111 | + if (_medthodType == RegisterMethodPhone && _stepIndex >= 2 && _myRegister.password.length > 0) {//顺序来到的第二步,不允许直接返回 | ||
| 112 | + self.navigationController.interactivePopGestureRecognizer.enabled = NO; | ||
| 113 | + } | ||
| 98 | 114 | } | |
| 99 | 115 | ||
| 100 | 116 | - (void)viewWillDisappear:(BOOL)animated{ | |
| 101 | 117 | [super viewWillDisappear:animated]; | |
| 102 | 118 | [self.view endEditing:YES]; | |
| 119 | + self.navigationController.interactivePopGestureRecognizer.enabled = YES; | ||
| 103 | 120 | } | |
| 104 | 121 | ||
| 105 | 122 | - (EaseInputTipsView *)inputTipsView{ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,36 @@ | |||
| 1 | + // | ||
| 2 | + // UIViewController+BackButtonHandler.h | ||
| 3 | + // | ||
| 4 | + // Created by Sergey Nikitenko on 10/1/13. | ||
| 5 | + // Copyright 2013 Sergey Nikitenko. All rights reserved. | ||
| 6 | + // | ||
| 7 | + // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 8 | + // of this software and associated documentation files (the "Software"), to deal | ||
| 9 | + // in the Software without restriction, including without limitation the rights | ||
| 10 | + // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 11 | + // copies of the Software, and to permit persons to whom the Software is | ||
| 12 | + // furnished to do so, subject to the following conditions: | ||
| 13 | + // | ||
| 14 | + // The above copyright notice and this permission notice shall be included in | ||
| 15 | + // all copies or substantial portions of the Software. | ||
| 16 | + // | ||
| 17 | + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 18 | + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 19 | + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 20 | + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 21 | + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 22 | + // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 23 | + // THE SOFTWARE. | ||
| 24 | + // | ||
| 25 | + | ||
| 26 | + #import <UIKit/UIKit.h> | ||
| 27 | + | ||
| 28 | + @protocol BackButtonHandlerProtocol <NSObject> | ||
| 29 | + @optional | ||
| 30 | + // Override this method in UIViewController derived class to handle 'Back' button click | ||
| 31 | + -(BOOL)navigationShouldPopOnBackButton; | ||
| 32 | + @end | ||
| 33 | + | ||
| 34 | + @interface UIViewController (BackButtonHandler) <BackButtonHandlerProtocol> | ||
| 35 | + | ||
| 36 | + @end | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,64 @@ | |||
| 1 | + // | ||
| 2 | + // UIViewController+BackButtonHandler.m | ||
| 3 | + // | ||
| 4 | + // Created by Sergey Nikitenko on 10/1/13. | ||
| 5 | + // Copyright 2013 Sergey Nikitenko. All rights reserved. | ||
| 6 | + // | ||
| 7 | + // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 8 | + // of this software and associated documentation files (the "Software"), to deal | ||
| 9 | + // in the Software without restriction, including without limitation the rights | ||
| 10 | + // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 11 | + // copies of the Software, and to permit persons to whom the Software is | ||
| 12 | + // furnished to do so, subject to the following conditions: | ||
| 13 | + // | ||
| 14 | + // The above copyright notice and this permission notice shall be included in | ||
| 15 | + // all copies or substantial portions of the Software. | ||
| 16 | + // | ||
| 17 | + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 18 | + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 19 | + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 20 | + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 21 | + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 22 | + // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 23 | + // THE SOFTWARE. | ||
| 24 | + // | ||
| 25 | + | ||
| 26 | + #import "UIViewController+BackButtonHandler.h" | ||
| 27 | + | ||
| 28 | + @implementation UIViewController (BackButtonHandler) | ||
| 29 | + | ||
| 30 | + @end | ||
| 31 | + | ||
| 32 | + @implementation UINavigationController (ShouldPopOnBackButton) | ||
| 33 | + | ||
| 34 | + - (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item { | ||
| 35 | + | ||
| 36 | + if([self.viewControllers count] < [navigationBar.items count]) { | ||
| 37 | + return YES; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + BOOL shouldPop = YES; | ||
| 41 | + UIViewController* vc = [self topViewController]; | ||
| 42 | + if([vc respondsToSelector:@selector(navigationShouldPopOnBackButton)]) { | ||
| 43 | + shouldPop = [vc navigationShouldPopOnBackButton]; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + if(shouldPop) { | ||
| 47 | + dispatch_async(dispatch_get_main_queue(), ^{ | ||
| 48 | + [self popViewControllerAnimated:YES]; | ||
| 49 | + }); | ||
| 50 | + } else { | ||
| 51 | + // Workaround for iOS7.1. Thanks to @boliva - http://stackoverflow.com/posts/comments/34452906 | ||
| 52 | + for(UIView *subview in [navigationBar subviews]) { | ||
| 53 | + if(subview.alpha < 1.) { | ||
| 54 | + [UIView animateWithDuration:.25 animations:^{ | ||
| 55 | + subview.alpha = 1.; | ||
| 56 | + }]; | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + return NO; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @end | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments