现在没时间整理,先把代码贴出来,以后再做详细的思路整理。

1 在AppController.mm的didFinishLaunchingWithOptions方法里面获取本地应用版本信息,保存起来。

 // about App version
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString *versionStr = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
SettingsManager::getInstancePtr()->getShortVersion() = [ versionStr UTF8String ];

2 在加载页面,使用http向服务器版本信息,如果返回的版本信息和在第一步中得到的不一致,进入混编文件。

  这只是一些参数。

 //转到appstore 里面
std::string t = MessageManage::getInstancePtr()->getStrMessage(String_Alter_Version_Title);
std::string c = MessageManage::getInstancePtr()->getStrMessage(String_Alter_Version_Content);
std::string b = MessageManage::getInstancePtr()->getStrMessage(String_Alter_Version_Btn);
ICheckVersionHelper::getInstancePtr()->alertView(t,c,b);

3 我把具体的类都贴上来,包括

ICheckVersionHelper.h  ICheckVersionHelper.app

CheckVersionHelperWin32.h CheckVersionHelperWin32.app

CheckVersionHelperIOS.mm CheckVersionHelperIOS.h

ICheckVersionHelper.h

#ifndef __ICheckVersionHelper_H__
#define __ICheckVersionHelper_H__ #include "cocos2d.h"
class ICheckVersionHelper
{
public:
ICheckVersionHelper(); virtual ~ICheckVersionHelper(); static ICheckVersionHelper * getInstancePtr(); virtual void alertView(std::string titlestr,std::string contentstr,std::string btnstr) {} }; #endif// #ifndef __ICheckVersionHelper_H__

ICheckVersionHelper.app

#include "PrecompiledHeader.h"
#include "ICheckVersionHelper.h" ICheckVersionHelper::ICheckVersionHelper()
{
} ICheckVersionHelper::~ICheckVersionHelper()
{
}

CheckVersionHelperWin32.h

#ifndef __CheckVersionHelperWin32_H__
#define __CheckVersionHelperWin32_H__ #include "ICheckVersionHelper.h" class CheckVersionHelperWin32 : public ICheckVersionHelper
{
public:
CheckVersionHelperWin32(); ~CheckVersionHelperWin32(); static CheckVersionHelperWin32 * getInstancePtr(); private:
static CheckVersionHelperWin32 m_Singleton; }; #endif// #ifndef __CheckVersionHelperWin32_H__

CheckVersionHelperWin32.app

#include "PrecompiledHeader.h"
#include "CheckVersionHelperWin32.h" CheckVersionHelperWin32 CheckVersionHelperWin32::m_Singleton; ICheckVersionHelper * ICheckVersionHelper::getInstancePtr()
{
return ( CheckVersionHelperWin32::getInstancePtr() );
} CheckVersionHelperWin32::CheckVersionHelperWin32()
{
} CheckVersionHelperWin32::~CheckVersionHelperWin32()
{
} CheckVersionHelperWin32 * CheckVersionHelperWin32::getInstancePtr()
{
return ( &m_Singleton );
}

CheckVersionHelperIOS.h

#ifndef __CheckVersionHelperIOS_H__
#define __CheckVersionHelperIOS_H__ #include "ICheckVersionHelper.h"
#import <UIKit/UIKit.h> @interface CheckVersionHelper : UIViewController<UIAlertViewDelegate> {
}
@property (nonatomic,retain) NSString *mytitle;
@property (nonatomic,retain) NSString *mycontent;
@property (nonatomic,retain) NSString *mybtn;
- (void) showMyView;
@end class CheckVersionHelperIOS : public ICheckVersionHelper
{
public:
void alertView(std::string titlestr,std::string contentstr,std::string btnstr) override; static CheckVersionHelperIOS * getInstancePtr(); protected:
CheckVersionHelperIOS() {} ~CheckVersionHelperIOS() {} private:
static CheckVersionHelperIOS m_Singleton; }; #endif

CheckVersionHelperIOS.mm 里面的apple id 我瞎写的。

#include "CheckVersionHelperIOS.h"

@implementation CheckVersionHelper

- (id) init
{
return self;
} - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == [alertView cancelButtonIndex]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=7100000"]];
}
}
- (void)showMyView
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil
message:self.mycontent
delegate:self
cancelButtonTitle:self.mybtn
otherButtonTitles:nil,nil];
[alert show];
[alert release];
}
@end ICheckVersionHelper * ICheckVersionHelper::getInstancePtr()
{
return ( CheckVersionHelperIOS::getInstancePtr() );
} CheckVersionHelperIOS CheckVersionHelperIOS::m_Singleton; CheckVersionHelperIOS * CheckVersionHelperIOS::getInstancePtr()
{
return ( &m_Singleton );
}
void CheckVersionHelperIOS::alertView(std::string titlestr,std::string contentstr,std::string btnstr)
{
CheckVersionHelper * myhelper = [[CheckVersionHelper alloc] init];
[myhelper setMytitle:[NSString stringWithUTF8String:titlestr.c_str()]];
[myhelper setMycontent:[NSString stringWithUTF8String:contentstr.c_str()]];
[myhelper setMybtn:[NSString stringWithUTF8String:btnstr.c_str()]];
[myhelper showMyView ];
}

ios的app,有新版本时必须先更新。的更多相关文章

  1. iOS APP下载安装时,如果出现此时无法下载安装APP的字样时,一些解决思路

    1.在iosAPP下载安装时,如果出现此时无法下载安装APP的字样时,可能是苹果系统进行了支持更新,并需要我们确认条约.至于如何判断是否是苹果系统进行了更改,只需要我们进入开发者账号,进入我的账户(A ...

  2. [App Store Connect帮助]一、 App Store Connect 使用入门(4)iOS 版 App Store Connect

    通过 iOS 版 App Store Connect,您可以在移动设备上查看销售数据.App 元数据和顾客评论.您还可以检查 App 状态.发布您 App 的新版本并回应“Resolution Cen ...

  3. ios h5 app avalon tap点击事件失效及点击延迟300ms问题解决方法

    1.ios h5 app avalon tap事件失效 使用MUI制作app界面,使用avalon.js渲染数据,发现在(Android上正常)ios上运行时容器div的avalon的ms-on-ta ...

  4. 【如何快速的开发一个完整的iOS直播app】(播放篇)

    原文转自:袁峥Seemygo    感谢分享.自我学习 前言 在看这篇之前,如果您还不了解直播原理,请查看上篇文章如何快速的开发一个完整的iOS直播app(原理篇) 开发一款直播app,集成ijkpl ...

  5. 【如何快速的开发一个完整的iOS直播app】(原理篇)

    原文转自:袁峥Seemygo    感谢分享.自我学习 目录 [如何快速的开发一个完整的iOS直播app](原理篇) [如何快速的开发一个完整的iOS直播app](播放篇) [如何快速的开发一个完整的 ...

  6. iOS:app直播---原理篇

    [如何快速的开发一个完整的iOS直播app](原理篇) 转载自简书@袁峥Seemygo:http://www.jianshu.com/p/7b2f1df74420   一.个人见解(直播难与易) 直播 ...

  7. iOS设置app应用程序文件共享

    1.iOSapp应用程序文件共享 当我们用itnues连接到设备时,在应用程序栏目下面,文件共享下,点击 对应的程序,即可以在程序右边栏目里面看到应用程序共享的数据, 此时,我们可以通过右下角的 添加 ...

  8. 如何快速的开发一个完整的iOS直播app(原理篇)

    目录 [如何快速的开发一个完整的iOS直播app](原理篇) [如何快速的开发一个完整的iOS直播app](播放篇) [如何快速的开发一个完整的iOS直播app](采集篇) 前言 大半年没写博客了,但 ...

  9. iOS 的 APP 在系统中如何适配不同的屏幕的尺寸

    iOS 的 APP 在系统中如何适配不同的屏幕的尺寸 标签: 2007年,初代iPhone发布,屏幕的宽高是 320 x 480 像素.下文也是按照宽度,高度的顺序排列.这个分辨率一直到iPhone ...

随机推荐

  1. lintcode-171-乱序字符串

    171-乱序字符串 给出一个字符串数组S,找到其中所有的乱序字符串(Anagram).如果一个字符串是乱序字符串,那么他存在一个字母集合相同,但顺序不同的字符串也在S中. 注意事项 所有的字符串都只包 ...

  2. PHPcms企业黄页中,会员注册之后提示经营模式不得少于1个字符 的解决办法

    后台--模块- 黄页模块 ---  企业库 --- 字段 ---   经营模式 ---  字符长度取值范围 1  改为  0. 

  3. string字符串比较和替换

    我用的是小写的string!! #include <string> #include <iostream> using namespace std; int main() { ...

  4. vs中编译连接时的警告屏蔽

    编译警告类型为warning C4996的形式 可以采用的#pragma warning(disable:4996)屏蔽掉这种编译警告 连接警告类型为warning LNK4049的形式 这是由于不同 ...

  5. [C/C++] 结构体存储问题

    64位操作系统,不同类型变量对应的字节数为: char : 1个字节 char*(即指针变量) : 8个字节 //32位占4个字节 short int : 2个字节 int : 4个字节 unsign ...

  6. delphi鼠标状态

    Screen.Cursor := crNo;

  7. nginx日志切割总结

    Nginx日志切割   方法1(脚本+定时执行): #step1:加脚本 cut_nginx_log.sh,主进程把USR1信号发给worker,worker接到这个信号后,会重新打开日志文件 #!/ ...

  8. AD高级培训PPT总结

    AD高级培训PPT总结 https://bbs.sangfor.com.cn/forum.php?mod=viewthread&tid=44905&highlight=     说明: ...

  9. cf 443 D. Teams Formation](细节模拟题)

    cf 443 D. Teams Formation(细节模拟题) 题意: 给出一个长为\(n\)的序列,重复\(m\)次形成一个新的序列,动态消除所有k个连续相同的数字,问最后会剩下多少个数(题目保证 ...

  10. PHP导出excel,无乱码

    php部分 header("Content-type:application/octet-stream"); header("Accept-Ranges:bytes&qu ...