彈出這個時機很重要,畢竟客戶也是相當厭煩彈窗和通知這類東西動不動就彈一個選擇題,妨礙其他操作,很不友好,但是有些功能需要在適當?shù)臅r機彈出來告知用戶一些私人定制的信息和操作...
譬如:
///MARK: -引導(dǎo)添加App Store的評論
- (void)guideAppstoreComment{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
BOOL isNotGuide = [[defaults objectForKey:@"isNotGuideAppstore"] boolValue];
if (isNotGuide) {
return ;
}
//跳轉(zhuǎn)到評價頁面
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"評價一下" message:@"我們拼了命加班擂煞,只希望那個您能用的爽。給個五星好評吧親!" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"五星好評" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString *str = [NSString stringWithFormat: @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&id=%@",KJJYSAPPID];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}];
UIAlertAction *action2 =[UIAlertAction actionWithTitle:@"稍后評價" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
UIAlertAction *action3 =[UIAlertAction actionWithTitle:@"不再提示" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[defaults setObject:@"YES" forKey:@"isNotGuideAppstore"];
[defaults synchronize];
}];
[alertVC addAction: action1];
[alertVC addAction: action2];
[alertVC addAction: action3];
[self presentViewController: alertVC animated:YES completion:^{
}];
}