勤之时 - 表示层(二)

2017-03-28  本文已影响91人  启发禅悟

应用很早就上线了,欢迎大家下载使用:http://itunes.apple.com/app/id1206687109

源码已经公开,大家可以去https://github.com/Inspirelife96/ILDiligence下载。 喜欢的话Fork或者给个Star,非常感谢。

下面是这一系列的全部帖子:
想法和原型
勤之时 - 架构与工程组织结构
勤之时 - 数据持久层的实现
勤之时 - 网络层的实现
勤之时 - 业务逻辑层
勤之时 - Info.plist的改动
勤之时 - 表示层(一)
勤之时 - 表示层(二)
勤之时 - 表示层(三)
勤之时 - 表示层(四)
勤之时 - 表示层(五)

从易到难,来看4个功能按钮的实现,这一节讲【设置】相关的功能实现。

功能描述

Setting Controllers.png

【设置】View Controller

【关于】View Controller

MVC设计考虑:

ILDSettingViewController的编码:

- (UITableView *)settingListTableView {
    if (!_settingListTableView) {
        _settingListTableView = [[UITableView alloc] init];;
        _settingListTableView.delegate = self;
        _settingListTableView.dataSource = self;
        _settingListTableView.tableFooterView = [[UIView alloc] init];
        _settingListTableView.separatorInset = UIEdgeInsetsMake(0, 12, 0, 12);
        _settingListTableView.tableHeaderView = [[ILDLogoView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, ScreenHeight - 128 - 4 * 44)];
        [_settingListTableView setBackgroundColor:ClearColor];
    }
    
    return _settingListTableView;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ILDSettingDefaultCell *defaultCell = [[ILDSettingDefaultCell alloc] init];
    
    if (indexPath.row == 0) {
        defaultCell.textLabel.text = @"意见与反馈";
        defaultCell.imageView.image = [UIImage imageNamed:@"menu_feedback_26x26_"];
        return defaultCell;
    } else if (indexPath.row == 1) {
        defaultCell.textLabel.text = @"给我打分";
        defaultCell.imageView.image = [UIImage imageNamed:@"menu_rate_26x26_"];
        return defaultCell;
    } else {
        defaultCell.textLabel.text = @"关于";
        defaultCell.imageView.image = [UIImage imageNamed:@"menu_about_26x26_"];
        return defaultCell;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        NSString *subject = @"勤之时 用户反馈";
        NSArray *recipientArray = [NSArray arrayWithObject: @"inspirelife@hotmail.com"];
        NSString *body = @"";
        
        NSDictionary *emaidContentDict = [NSDictionary dictionaryWithObjectsAndKeys:
                                          subject, @"subject",
                                          recipientArray, @"recipients",
                                          body, @"body",
                                          nil];
        
        [self sendMailInApp:emaidContentDict];
    } else if (indexPath.row == 1){
        if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:kAppReviewURL] options:@{} completionHandler:^(BOOL success) {
            }];
        } else {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:kAppReviewURL]];
        }
    } else {
        ILDAboutViewController *aboutVC = [[ILDAboutViewController alloc] init];
        [self presentViewController:aboutVC animated:YES completion:nil];
    }
}

ILDAboutViewController的编码:

    if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:kPayURL] options:@{} completionHandler:^(BOOL success) {
        }];
    } else {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:kPayURL]];
    }

这个功能是怎么实现的?这里不需要注册额外的什么支付宝开发等等,主要的就是怎么找到这个Schema

NSString *const kPayURL = @"alipayqr://platformapi/startapp?saId=10000007&qrcode=HTTPS://QR.ALIPAY.COM/xxxxxxxxxxxxxxxx";

最后一串就是你的支付宝ID对应的二维编码解析得到的结果。你可以打开支付宝,找到自己的二维码,然后Decoder这个二维码,你就会发现HTTPS://QR.ALIPAY.COM/xxxxxxxxxxxxxxxx这一串代码,然后代替上面的就可以了。

上一篇 下一篇

猜你喜欢

热点阅读