关闭

iOS开发知识点汇集三 —— Delegate的使用

489人阅读 评论(0) 收藏 举报

一、UIApplicationDelegate

- (void)applicationDidFinishLaunching:(UIApplication *)application    //启动完成
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions    //同上,带启动参数,推荐使用
- (void)applicationWillEnterForeground:(UIApplication *)application    //将要进入前台,首次启动不调用applicationWillEnterForeground,只有从后台再次进入前台时才调用
- (void)applicationDidBecomeActive:(UIApplication *)application    //进入前台
- (void)applicationWillResignActive:(UIApplication *)application    //将要退到后台
- (void)applicationDidEnterBackground:(UIApplication *)application    //退到后台
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert| UIRemoteNotificationTypeSound]; //设置push通知参数
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken //设置成功
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error //设置失败
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo //收到push通知
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification //收到本地通知

二、跳转AppStore

1、跳转应用详情页

NSURL *appUrl = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/cn/app/id%d?mt=8",ituneId]];
[[UIApplication sharedApplication] openURL:appUrl];

2、跳转应用评价页

NSURL *appUrl = [NSURL URLWithString:[NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%d", itunesID]];
[[UIApplication sharedApplication] openURL:appUrl];



3、跳转兑换码页

NSURL *appUrl = [NSURL URLWithString:[NSString stringWithFormat:@"https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/redeemLandingPage?code=%@", @"EEW94ALTYREW"]];
[[UIApplication sharedApplication] openURL:appUrl];


三、

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:12065次
    • 积分:173
    • 等级:
    • 排名:千里之外
    • 原创:4篇
    • 转载:17篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档