iOS常用代码

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
     // The device is an iPad running iOS 3.2 or later.
}
else {
     // The device is an iPhone or iPod touch.
}

一.本地通知

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    dispatch_async(dispatch_get_main_queue(), ^{
        UILocalNotification * localNotification = [[UILocalNotification alloc] init];
        if (localNotification) {
            localNotification.fireDate= [[[NSDate alloc] init] dateByAddingTimeInterval:5];
            localNotification.timeZone=[NSTimeZone defaultTimeZone];
            localNotification.alertBody = @"客户端有新的版本,点击到App Store升级。";
            localNotification.alertAction = @"升级";
            localNotification.soundName = @"";
            [application scheduleLocalNotification:localNotification];
        }
    });
}

二.判断是pad还是phone

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
    // open app store link
    NSString * url = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@", @"10123"];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}

三.是否有类或者有该方法

if ([UIPrintInteractionController class]) {
   // Create an instance of the class and use it.
}
else {
   // The print interaction controller is not available.
}

To determine whether a method is available on an existing class, use the instancesRespondToSelector: class method or the respondsToSelector: instance method.




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值