- //*******************************代码********************
- #define SYSTEM_IOS7(SYSTEM_VERSION >= 7.0 ? YES: NO) //iOS7以上 宏定义
- NSString * urlStr = @"";
- if (SYSTEM_IOS7) //IOS7 以上的url发生了变化,因此判断下系统版本
- {
- urlStr = @"itms-apps://itunes.apple.com/app/id888888888"; //8888888 换成都自己的应用id即可
- } else {
- urlStr = @"itms-apps://ax.itunes.apple.com/webObjects/MZStore.woa/wa/viewContentsUserReviews?mt=8&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software&id=888888888"; //url的参数带有详细分页,页码数,版本,如不需要也可去掉
- }
- NSURL * aUrl = [NSURLURLWithString: urlStr];
- BOOL isOpen = [[UIApplicationsharedApplication] canOpenURL: aUrl]; //判断url能否被打开,一个保护机制
- if (isOpen) { [[UIApplicationsharedApplication] openURL: [NSURLURLWithString: urlStr]];
- } else {
- NSLog(@"无法打开!"); //可以弹出一个alterView,本人只是写了个log
- }
- //***************代码结束**********************
来源: http://lib.csdn.net/snippet/ios/42285