iOS开发10万个为什么

1.提交审核 的时候第三方新浪分享SinaWeiboSDK/libWeiboSDK.a包含广告标识符 (IDFA),除了删除,该选哪个选项?
![OJL2Q2B)$23L]]LJHU}}~UN.jpg](http://upload-images.jianshu.io/upload_images/1430247-ea69bcfb9adc2fc2.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

2.怎么判断一个日期距离现在有多久时间?

// 时间字符串NSString *createdAtString = @"2015-11-20 11:10:05";
NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
fmt.dateFormat = @"yyyy-MM-dd HH:mm:ss";
NSDate *createdAtDate = [fmt dateFromString:createdAtString];// 手机当前时间
NSDate *nowDate = [NSDate date];/** NSComparisonResult的取值 
NSOrderedAscending = -1L, // 升序, 越往右边越大 NSOrderedSame, // 相等 
NSOrderedDescending // 降序, 越往右边越小 */// 获得比较结果(谁大谁小)
NSComparisonResult result = [nowDate compare:createdAtDate];
if (result == NSOrderedAscending) { // 升序, 越往右边越大 NSLog(@"createdAtDate > nowDate");
} else if (result == NSOrderedDescending) { // 降序, 越往右边越小 NSLog(@"createdAtDate < nowDate");
} else {
 NSLog(@"createdAtDate == nowDate");
}
   NSDateFormatter * fmt = [[NSDateFormatter alloc] init];
    fmt.dateFormat =@"HH : mm : ss";
    fmt.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh"];
    NSDate * date = [NSDate date];
     NSLog (@"%@",[fmt stringFromDate:date]);
    NSDate * dateAfter5 = [date dateByAddingMinutes:5];
     NSLog (@"%@",[fmt stringFromDate:dateAfter5]);

3.打印字典出现 msg = "\U53c2\U6570\U6821\U9a8c\U9519\U8bef;
取自某SDK

- (NSString *)logDic:(NSDictionary *)dic {
    if (![dic count]) {
        return nil;
    }
    NSString *tempStr1 =
    [[dic description] stringByReplacingOccurrencesOfString:@"\\\\u"
                                                 withString:@"\\\\U"];
    NSString *tempStr2 =
    [tempStr1 stringByReplacingOccurrencesOfString:@"\\"" withString:@"\\\\\\""];
    NSString *tempStr3 =
    [[@"\\"" stringByAppendingString:tempStr2] stringByAppendingString:@"\\""];
    NSData *tempData = [tempStr3 dataUsingEncoding:NSUTF8StringEncoding];
    NSString *str =
    [NSPropertyListSerialization propertyListFromData:tempData
                                     mutabilityOption:NSPropertyListImmutable
                                               format:NULL
                                     errorDescription:NULL];
    HJLog(@"%@",str);
    return str;
}

4.怎么获取tableview 最后一个cell
判断indexPath.row == models.count -1

5.字符串根据逗号分隔

NSArray * timeArray = [slotTime componentsSeparatedByString:@","];

6.打包api,确认bundleID 是对的,却提示无效?


iOS开发10万个为什么_第1张图片
Paste_Image.png

解决:
删掉对应证书,xcode-preferences,选中账号,-viewdetails, reset对应证书,create对应描述文件


iOS开发10万个为什么_第2张图片
Paste_Image.png
  1. 2016-3-25 格式 怎么去掉年份,转换成 3月25号?
    1.先将日期字符串,转成date,
    2.再设置fmt的格式为 M月dd号
    3.再转为字符串
    http://www.tuicool.com/articles/Mfa6fy6
    iOS开发10万个为什么_第3张图片
    Paste_Image.png

8.出现Illegal redeclaration of property in class extension错误

Paste_Image.png

解决: 粗心所致. 重复声明了属性,.h 和.m 都声明了这个属性

9.dismiss 控制器 使用通知 传值回到之前的控制器,通知方法没触发
解决:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(AAAA:) name:@"AAAA" object:self];
object填nil ,表示接受任意对象发出的通知,object可限定只接受某个对象发出的通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(AAAA:) name:@"AAAA" object:nil];
    ```
10. UIStoryboard 加载出来的控制器为nil

UIStoryboard * sd = [UIStoryboard storyboardWithName:NSStringFromClass([DGPersonalViewController class]) bundle:nil];
DGPersonalViewController * pVC = [sd instantiateInitialViewController];

解决:
![Paste_Image.png](http://upload-images.jianshu.io/upload_images/1430247-2c7aec800c1e5039.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

11. CATransition 的 type 和subType 有什么区别?
    
![Paste_Image.png](http://upload-images.jianshu.io/upload_images/1430247-7f56c7ac41a370e4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

12.自定义push动画

13.对象归档失败
每次应用启动,其目录名称会随机生成一段字母做凭借,所以不能保存整条路径,应该保存后缀,每次重新拼接路径.
http://blog.csdn.net/liliangchw/article/details/8314123

14.如何给Xcode7.2 增加9.3的配置包?
在应用程序找到Xcode,显示内容,找到路径
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport

15.AFN配置HTTPS请求,以及设置请求超时时间
  • (AFHTTPSessionManager *)manager
    {
    @synchronized (self) {
    if (!_manager) {
    _manager = [AFHTTPSessionManager manager];
    //配置https
    AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];

          policy.allowInvalidCertificates = YES;//接收无效的证书,默认是NO
          
          policy.validatesDomainName = NO;    //不验证域名
          
          _manager.securityPolicy = policy;
          
          [_manager.requestSerializer setTimeoutInterval:120];
      }
    

    }
    return _manager;
    }

16.如何让多个动画按顺序执行?

[UIView animateKeyframesWithDuration:duration delay:0.0
options:UIViewKeyframeAnimationOptionCalculationModeCubic animations:^{
// relativeDuration参数是百分比,不是时长
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.5
animations:^{
fromViewController.view.frame = shrunkenFrame;
toViewController.view.alpha = 0.5;
}];

                                 [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.5
                                                               animations:^{
                                                                   fromViewController.view.frame = fromFinalFrame;
                                                                   toViewController.view.alpha = 1.0;
                                                               }];
                                 
                             }completion:^(BOOL finished) {
                                 [transitionContext completeTransition:YES];
                             }];
17.在Switch case里面 声明零时变量报错?
在代码里面加{}

case UIGestureRecognizerStateChanged: {
CGFloat fraction = 1.0 - gestureRecognizer.scale / _startScale;
_shouldCompleteTransition = (fraction > 0.5);
[self updateInteractiveTransition:fraction];
break;
}

18. 企业级APP 网络下载失败?如图

![Paste_Image.png](http://upload-images.jianshu.io/upload_images/1430247-64f77fedcff532e2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)



![Paste_Image.png](http://upload-images.jianshu.io/upload_images/1430247-7b2e254782a7af5e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


原因:plist文件里面配置�的图片地址失效,导致下载不成功,修改为正确地址即可

19.隐身术使用私有API
   SEL my_sel = NSSelectorFromString([NSString stringWithFormat:\
@"%@%@%@", "se","tOr","ientation:"]);
    [UIDevice performSelector:my_sel ...];
20. OC 调用Swift库,无法识别 $(SWIFT_MODULE_NAME)-Swift.h?
必须在你的项目创建一个Swift文件,让Xcode生成下图的配置
![50B81EA7-2865-4D03-B6E2-91D4A425DB75.png](http://upload-images.jianshu.io/upload_images/1430247-cc361d0d4bb7419e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
21. 使用Cocoapods的Xcode项目放在Window系统,再放到Mac使用会报错?
原因:Podfile,Podfile.lock文件被篡改导致

![72288054-6708-4A0D-A962-A740982C0A95.png](http://upload-images.jianshu.io/upload_images/1430247-22804fff08e0b2d4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
22.jks证书转化为pem格式
sert.jks 转为 sert.p12
keytool -importkeystore -srckeystore sert.jks -destkeystore sert.p12 -srcstoretype jks -deststoretype pkcs12 **-alias keyOwnerAlias**

sert.p12 转为 sert.pem
openssl pkcs12 -in sert.p12 -out sert.pem
http://blog.csdn.net/u012046327/article/details/45369175
23.如何在IB界面适配不同屏幕尺寸,修改UILabel的字体大小?
左边+号添加字体
![图片.png](http://upload-images.jianshu.io/upload_images/1430247-700e4bc596220a11.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

24.storyboard segue里面的 show,showDetail有什么区别?
show,就是push,已压栈形式压入控制器
showDetail,是应用于UISplitViewController,直接替换控制器,不是堆栈形式(仅限同时显示master和Detail的情况下,只显示其中一个的话就跟push一样)

你可能感兴趣的:(iOS开发10万个为什么)