IOS开源项目Coding学习笔记(3):注册界面RegisterViewController

来源:互联网 发布:js ajax请求跨域问题 编辑:程序博客网 时间:2024/06/05 15:07
  1. - (void)registerBtnClicked{
  2.    RegisterViewController *vc = [[RegisterViewController alloc] init];
  3.    UINavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:vc];
  4.    [self presentViewController:nav animated:YES completion:nil];
  5. }

 1、整个界面组成:


1.1、NavigationBar

  1. -(void)viewWillAppear:(BOOL)animated{
  2.    [super viewWillAppear:animated];
  3.    [self.navigationController setNavigationBarHidden:NO animated:YES];
  4.    
  5. }

1.2、TPKeyboardAvoidingTableView -- 开源控件

https://github.com/michaeltyson/TPKeyboardAvoiding


2、tableView 的 footerView

  1. - (UIView *)customFooterView{
  2.    UIView *footerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 150)];
  3.    _footerBtn = [UIButton buttonWithStyle:StrapSuccessStyle andTitle:@"立即体验" andFrame:CGRectMake(kLoginPaddingLeftWidth, 20, kScreen_Width-kLoginPaddingLeftWidth*2, 45) target:self action:@selector(sendRegister)];
  4.    [footerV addSubview:_footerBtn];  //buttonWithStyle定制了一些通用的按钮

            //主要是ReactiveCocoa的使用,暂时我也不是很明白,但是挺重要的,很多人在用,我在下面列了一些参考         //文章

  1.    RAC(self, footerBtn.enabled) = [RACSignal combineLatest:@[RACObserve(self, myRegister.email), RACObserve(self, myRegister.global_key), RACObserve(self, myRegister.j_captcha), RACObserve(self, captchaNeeded)] reduce:^id(NSString *email, NSString *global_key, NSString *j_captcha, NSNumber *captchaNeeded){
  2.        if ((captchaNeeded && captchaNeeded.boolValue) && (!j_captcha || j_captcha.length <= 0)) {
  3.            return @(NO);
  4.        }else{
  5.            return @((email && email.length > 0) && (global_key && global_key.length > 0));
  6.        }
  7.    }];
  8.    
  9.    //基于网上的一个开源库https://github.com/TTTAttributedLabel/TTTAttributedLabel
  10.    UITTTAttributedLabel *lineLabel = ({
  11.        UITTTAttributedLabel *label = [[UITTTAttributedLabel alloc] init];
  12.        label.textAlignment = NSTextAlignmentCenter;
  13.        label.font = [UIFont systemFontOfSize:12];
  14.        label.textColor = [UIColor colorWithHexString:@"0x999999"];
  15.        label.numberOfLines = 0;
  16.        label.linkAttributes = kLinkAttributes;
  17.        label.activeLinkAttributes = kLinkAttributesActive;
  18.        label.delegate = self;
  19.        label;
  20.    });
  21.    NSString *tipStr = @"点击立即体验,即表示同意《coding服务条款》";
  22.    lineLabel.text = tipStr;
  23.    [lineLabel addLinkToTransitInformation:@{@"actionStr" : @"gotoServiceTermsVC"} withRange:[tipStr rangeOfString:@"《coding服务条款》"]];
  24.    
  25.    CGRect footerBtnFrame = _footerBtn.frame;
  26.    lineLabel.frame = CGRectMake(CGRectGetMinX(footerBtnFrame), CGRectGetMaxY(footerBtnFrame) +12, CGRectGetWidth(footerBtnFrame), 12);
  27.    [footerV addSubview:lineLabel];
  28.    
  29.    return footerV;
  30. }

3、

点击coding服务条款》进入一个webView界面,下一篇会分析下这个webView界面

  1. #pragma mark VC
  2. - (void)gotoServiceTermsVC{
  3.    NSString *pathForServiceterms = [[NSBundle mainBundle] pathForResource:@"service_terms" ofType:@"html"];
  4.    WebViewController *vc = [WebViewController webVCWithUrlStr:pathForServiceterms];
  5.    [self.navigationController pushViewController:vc animated:YES];
  6. }

4、ReactiveCocoa 这个也是很火的一个开源框架

参考文章:

http://benbeng.leanote.com/post/ReactiveCocoaTutorial-part2

http://limboy.me/ios/2013/12/27/reactivecocoa-2.html

http://www.jianshu.com/p/1fc8c809e2c0


0 0