iOS之面试题将来跳槽用

01-基础+UI面试题

2016-11-07  本文已影响473人  面试题大神

简单说一下APP的启动过程,从main文件开始说起

程序启动分为两类:1.有storyboard 2.没有storyboard

有storyboard情况下:
1. main函数
2. UIApplicationMain
    创建UIApplication对象
    创建UIApplication的delegate对象
3. 根据Info.plist获得Main.storyboard的文件名,加载Main.storyboard 
4. 创建UIWindow
5. 创建和设置UIWindow的rootViewController
6. 显示窗口

没有storyboard情况下:
1. main函数
2. UIApplicationMain
    创建UIApplication对象
    创建UIApplication的delegate对象
3. delegate对象开始处理(监听)系统事件
4. 调用application:didFinishLaunchingWithOptions:方法并在其中创建UIWindow
5. 创建和设置UIWindow的rootViewController
6. 显示窗口

简述一下UIViewController的生命周期?

loadView的作用?

- (void)loadView
{ 
    self.view = [[UIImageView alloc] init];
}

控制器通过Storyboard或者Xib创建时的注意事项?

详细blogLink

xib如何动态处理view布局

frame和bounds的区别 ?

    UIView *v1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
    v1.backgroundColor = [UIColor redColor];
    [self.view addSubview:v1];
    
    UIView *v2 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    v2.backgroundColor = [UIColor greenColor];
    [v1 addSubview:v2];

以上代码得出的效果图:

改变v1的bounds前

添加代码v1.bounds = CGRectMake(0, 0, 200, 200)后的效果图:

改变v1的bounds后

drawRect 和 layoutSubViews 有什么区别 ?

iOS有几种动画,各自是什么?

动画详解Link

如何实现一个图形沿一个固定路径移动 ?

 CALayer *redLayer = [CALayer layer];
    redLayer.backgroundColor = [UIColor redColor].CGColor;
    redLayer.frame = CGRectMake(150, 0, 100, 100);
    redLayer.cornerRadius = 50;
    [self.view.layer addSublayer:redLayer];
    
    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    animation.duration = 3.f;
    animation.repeatCount = MAXFLOAT;
    
    CGMutablePathRef path = CGPathCreateMutable();
    CGPathAddEllipseInRect(path, NULL, CGRectMake(0, 0, 300, 600));
    
    animation.path = path;
    [redLayer addAnimation:animation forKey:nil];
    
    CGPathRelease(path);

ScrollView的contentSize能在viewDidLoad里设置么,为什么?

页面间传值的方式有哪些

(详细博客)

如何自动计算Cell的高度

tableView.estimatedRowHeight = xx
tableView.rowHeight = UITableViewAutomaticDimension

CALayer和UIView的区别

UITableview的复用机制的原理

UIButton与UITableView的层级结构

同一个Lable的Text如何显示不同字体和颜色

   NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"hello"];  
// 第一个文字显示蓝色  
    [str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0, 1)];
//最后两个文字显示红色  
    [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(2, 2)];
      
// 在不同位置设置不同字体  
    [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30] range:NSMakeRange(1, 3)];  
    self.label.attributedText = str;  

说下webview与js的交互


如果需要一个有序的NSDictionary应该怎么处理?

断言的使用

深浅拷贝的区别和使用场景

    [NSString copy];           (浅拷贝)
    [NSMutableString copy];    (深拷贝)
    
    [NSString mutableCopy];    (深拷贝)
    [NSMutableString mutableCopy]; (深拷贝)

weak的使用情景?

assign和weak的区别?

详细博客第12题

说说 __block__weak的区别

instancetype与id的区别

#import和#include的区别, #import<>和 #import ""的区别, #import和@class的区别?

Objective-C中类别, 类扩展和继承的区别?

如何进行代码做自动布局

简述assign、retain、copy、weak和strong分别在什么情况下使用?

delegate用什么属性修饰,ARC下与MRC下有何不同,为什么?

详细博客第8题

NSString,NSArray,NSMutableArray分别用什么属性修饰,原因是什么?

详细博客

谈一下关键字const, static和extern的作用?

详细blogLink

int const a = 10;
a = 20
//因为变量a被const修饰,就成为了只读,不能被修改赋值了,
所以上面a = 20这行代码是错误的
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
   static int i = 0; 
   i ++; 
   NSLog(@"i=%d",i);}
//打印结果 (因为变量i在内存中只存在一份!)
   i = 1, i = 2, i = 3 ....
}
//声明一些全局常量
extern NSString * const name;
extern NSInteger const count;
#import <Foundation/Foundation.h>
//实现
NSString * const name = @"王五";
NSInteger const count = 3;

@property本质是什么

详细blog链接

OC语言三大特性的定义和特点以及各自的适用场景

封装

继承

多态

在OC里面,给指定类动态添加行为的方法有哪些

上一篇 下一篇

猜你喜欢

热点阅读