應(yīng)用很早就上線了柠掂,歡迎大家下載使用:http://itunes.apple.com/app/id1206687109
源碼已經(jīng)公開翁潘,大家可以去https://github.com/Inspirelife96/ILDiligence下載辜昵。 喜歡的話Fork或者給個Star,非常感謝症见。
下面是這一系列的全部帖子:
想法和原型
勤之時 - 架構(gòu)與工程組織結(jié)構(gòu)
勤之時 - 數(shù)據(jù)持久層的實現(xiàn)
勤之時 - 網(wǎng)絡(luò)層的實現(xiàn)
勤之時 - 業(yè)務(wù)邏輯層
勤之時 - Info.plist的改動
勤之時 - 表示層(一)
勤之時 - 表示層(二)
勤之時 - 表示層(三)
勤之時 - 表示層(四)
勤之時 - 表示層(五)
從易到難,來看4個功能按鈕的實現(xiàn)殃饿,這一節(jié)講【設(shè)置】相關(guān)的功能實現(xiàn)谋作。
功能描述
【設(shè)置】View Controller
- 點擊【設(shè)置】按鈕,以Present的形式顯示Setting Controller乎芳。
- 左上角是關(guān)閉按鈕遵蚜,點擊關(guān)閉Setting Controller
- Setting Controller基于Table View帖池。 上面是【勤之時】的ICON以及一些描述,Table List有3項內(nèi)容吭净,如圖睡汹。
- 底部是一行出品描述字
- 點擊【意見和反饋】Cell跳轉(zhuǎn)至郵件發(fā)送。
- 點擊【給我打分】Cell跳轉(zhuǎn)至Apple Store 【勤之時】的下載頁面
- 點擊【關(guān)于】按鈕攒钳,Present【關(guān)于】頁面
【關(guān)于】View Controller
- 中間為一首小詩
- 中下部有一個【贊賞】按鈕帮孔,點擊跳轉(zhuǎn)至支付寶客戶端,進行轉(zhuǎn)賬不撑。
- 【贊賞】按鈕下是一串描述文字文兢。
- 底部是【關(guān)閉】按鈕,點擊返回【設(shè)置】頁面焕檬。
MVC設(shè)計考慮:
- Controller:
- ILDSettingViewController:主要包含一個TableView姆坚,背景設(shè)置為虛化的主頁面。
- ILDAboutViewController:About的功能實現(xiàn)实愚,同樣兼呵,背景為虛化的主頁面。
- 考慮到背景都為虛化的主頁面腊敲,以及我們后續(xù)都需要這個以虛化的主頁面為背景的Controller击喂,這邊設(shè)計一個ILDBaseViewController,作為基類碰辅,主要用戶虛化的主頁面的背景設(shè)置懂昂。
- Model:
- 無
- View:
- ILDSettingViewController 需要 ILDLogoView,來作為Table View的headerView
- ILDSettingDefaultCell 為 Table View 的自定義Cell没宾。
ILDSettingViewController的編碼:
- settingListTableView的初始化凌彬,主要是添加ILDLogoView作為它的HeaderView
- (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;
}
- 以及settingListTableView的datasource和delegate
- (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 = @"關(guān)于";
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的編碼:
- 主要還是布局的問題。除了布局循衰,就是點贊的按鈕會跳轉(zhuǎn)到支付寶铲敛,向我發(fā)起支付
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:kPayURL] options:@{} completionHandler:^(BOOL success) {
}];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:kPayURL]];
}
這個功能是怎么實現(xiàn)的?這里不需要注冊額外的什么支付寶開發(fā)等等会钝,主要的就是怎么找到這個Schema
NSString *const kPayURL = @"alipayqr://platformapi/startapp?saId=10000007&qrcode=HTTPS://QR.ALIPAY.COM/xxxxxxxxxxxxxxxx";
最后一串就是你的支付寶ID對應(yīng)的二維編碼解析得到的結(jié)果伐蒋。你可以打開支付寶,找到自己的二維碼顽素,然后Decoder這個二維碼咽弦,你就會發(fā)現(xiàn)HTTPS://QR.ALIPAY.COM/xxxxxxxxxxxxxxxx這一串代碼,然后代替上面的就可以了胁出。