美文网首页
iOS UIAlertViewController定制版本更新弹

iOS UIAlertViewController定制版本更新弹

作者: LMGod | 来源:发表于2017-05-31 22:19 被阅读450次

开始我自定义的版本更新框是这样的:

前几天我看见了简书的版本更新的提示框,感觉不错就模仿写了一个

效果图如下:

所以下简单的思路吧:

1.首先请求项目的当前版本信息(boudleid为你自己项目的boudleid)

NSString *storeString = [NSString stringWithFormat:@"https://itunes.apple.com/lookup?bundleId=%@",boudleid];

2.对版本号进行比较,是否弹出提示框

3.至于提示框就很简单了

UIAlertController *alertController=[UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"发现新版本%@",currentVersion] message:releaseNotes preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *action0=[UIAlertAction actionWithTitle:@"下次再说" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

}];

UIAlertAction *action1=[UIAlertAction actionWithTitle:@"忽略此版本" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

}];

UIAlertAction *action2=[UIAlertAction actionWithTitle:@"前往更新" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:trackUrl]];

}];

[alertController addAction:action0];

[alertController addAction:action1];

[alertController addAction:action2];

[self.showController presentViewController:alertController animated:YES completion:nil];

最后在你所要展示的控制器写上一句代码就行了:

[LMUpdateVersionManage checkVersionInController:self];

完事!!

做完之后发现更新的内容提示是居中的,我想了下没想到如何让他居左对齐,回头看了下简书的,发现他也存在这个问题。而我之前做的提示信息,使用的一个tableview来展示的,发现比简书在这方面还是美观一点,项目里面还是用以前的吧^^^.

githubDemo地址:我的github

如果你有好的建议可以告诉我!!!

相关文章

  • iOS UIAlertViewController定制版本更新弹

    开始我自定义的版本更新框是这样的: 前几天我看见了简书的版本更新的提示框,感觉不错就模仿写了一个 效果图如下: 所...

  • iOS开发实战 - 如何更灵活的控制App版本更新

    自从iOS可以在设置中开启App自动更新后,越来越多的App不再弹框提示用户进行版本更新,尤其是强制更新,其实苹果...

  • iOS版本更新

    iOS APP版本 更新

  • iOS 上传AppStore 被拒汇总

    (1)、苹果要求版本更新必须使用iOS版本更新内置更新机制。 4. Design: Preamble Design...

  • iOS版本更新

    1、获取当前版本 NSString *current_version = [[[NSBundle mainBund...

  • iOS 版本更新

    获取本机版本号 NSDictionary *localDic = [[NSBundle mainBundle] i...

  • iOS版本更新

    版本更新 #pragma mark -检查版本更新 - (void)checkNewVersion { // NS...

  • iOS 版本更新

    众所周知苹果拒绝任何带有版本更新的提示出现在页面中,因此我们通过接口获取,处理是否显示更新提示。 1.判断版本号 ...

  • iOS 版本更新

    1.获取本地版本信息 2.获取App Store版本信息 3.新旧版本对比 代码: 请求的基类中获取App Sto...

  • iOS版本更新

    最近,应项目需求,简单写了一个版本更新的提示,有需要的码友可以去下载看看,实现起来比较简单。 效果图 首先是请求a...

网友评论

      本文标题:iOS UIAlertViewController定制版本更新弹

      本文链接:https://www.haomeiwen.com/subject/ueajfxtx.html