IOS UI考试试题(转载)

http://blog.sina.com.cn/s/blog_93c533fb0102veiq.html

※ 选择题(共25题,每题3分)

1、
当程序从后台将要重新回到前台的时候,会先执行以下哪个方法:
答案:(B)
A、- (void)applicationDidFinishLaunching:(UIApplication*)application{ }
B、- (void)applicationWillEnterForeground:(UIApplication *)application{ }
C、- (void)applicationDidBecomeActive:(UIApplication *)application{ }
D、 - (void)applicationWillTerminate:(UIApplication *)application{ }

2、
对于UISearchBar,要实现实时搜索(即搜索内容实时发生变化时),会执行以下哪个方法:
答案:(C)
A、- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar;
B、- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar;
C、- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{ }
D、- (void)searchBarResultsListButtonClicked:(UISearchBar *)searchBar{ }

3、
以下的代码会出现什么问题:@implementation Person- (void)setAge:(int)newAge {  self.age = newAge;}@end
答案:(B)
A、会造成循环引用
B、会造成死循环
C、会出现内存泄露
D、会出现野指针

4、
以下不属于ios中实现多线程的方法是:
答案:(D)
A、NSThread
B、NSOperationQueue
C、Grand Central Dispatch(GCD)
D、NSURLRequest

5、
以下对多线程开发的理解错误的是:
答案:(B)
A、发挥多核处理器的优势,并发执行让系统运行的更快、更流畅,用户体验更好
B、多线程程序中,一个进程包含2个以上的线程(含2个)
C、大量的线程降低代码的可读性,但不需要更多的内存空间
D、当多个线程对同一个资源出现争夺的时候要注意线程安全的问题

6、
下面对UIView、UIWindow和CALayer理解错误的是:
答案:(C)
A、UIView继承于UIResponder
B、UIResponder继承于NSObject,UIView可以响应用户事件。
C、UIResponder继承与NSObject,CALayer继承于NSObject,CALayer可以响应事件。
D、UIView是用来显示内容的,可以处理用户事件,CALayer是用来绘制内容的,依赖与UIView来进行显示

7、
对于UIScrollViewController,scrollView将开始降速时,执行的方法是:
答案:(D)
A、- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;{ }
B、- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;{ }
C、- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;{ }
D、- (void)scrollViewWillBeginDecelerating:

8、
对于UICollectionViewController,实现定义每个元素的margin(边缘 上-左-下-右) 的方法是:
答案:(B)
A、
- (CGSize)collectionView:(UICollectionView *)collectionView
 layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{  
 return CGSizeMake();  
}

B、
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView
 layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{  
 return UIEdgeInsetsMake();  
}

C、
- (CGSize)collectionView:(UICollectionView *)collectionView
 layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{      
 return CGSizeMake();  
}

D、
- (CGSize)collectionView:(UICollectionView *)collectionView
 layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
{  
 return CGSizeMake();  
}


9、
在MVC框架中,M与C通讯,通常使用什么方式?//M与C K与C都是通过KVO方式通讯
答案:(A)
A、KVO与通知
B、协议-代理
C、类目
D、属性

10、
以下关于导航栏外观属性对应的解释错误的是:
答案:(D)
A、barStyle bar的样式
B、translucent bar的透明度
C、backgroundImage bar的背景图片
D、barTintColor bar上控件的颜色  //改变导航栏的颜色

11、
实现一个singleton的类,下面正确的是:
答案:(A)
A、
static LOSingleton * shareInstance;
+ ( LOSingleton *)sharedInstance{
 @synchronized(self){
  if (shareInstance == nil) {
   shareInstance = [[self alloc] init];
  }
 }
 return shareInstance;
}

B、
static LOSingleton * shareInstance;
- ( LOSingleton *)sharedInstance{
 @synchronized(self){
  if (shareInstance == nil) {
   shareInstance = [[self alloc] init];
  }
 }
 return shareInstance;
}

C、
+ (LOSingleton *) sharedInstance
{
 LOSingleton *sharedInstance = nil ;
 static dispatch_once_t onceToken;  
 dispatch_once (& onceToken, ^ {  
  sharedInstance = [[self alloc] init];
 });
 return sharedInstance;
}

D、
- (LOSingleton *) sharedInstance
{
 static LOSingleton *sharedInstance = nil ;
 static  dispatch_once_t onceToken;  
 dispatch_once (& onceToken, ^ {  
  sharedInstance = [[self alloc] init];
 });
 return sharedInstance;
}


12、
以下哪个方法在当程序将要退出时被调用,且通常在此方法里写一些用来保存数据和一些退出前的清理工作。
答案:(B)
A、- (void)applicationExitsOnSuspend:(UIApplication *)application{ }
B、- (void)applicationDidEnterBackground:(UIApplication *)application{ }
C、- (void)applicationWillTerminate:(UIApplication *)application{ }
D、- (void)applicationDidFinishLaunching:(UIApplication *)application{ }

13、
获取tableview正在window上显示的cell的indexPath方法是:
答案:(B)
A、- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath;
B、- (NSArray *)indexPathsForVisibleRows;
C、- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
D、- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath;

14、
下面关于深拷贝与浅拷贝理解正确的是:
答案:(A)
A、深拷贝拷贝的是内容,浅拷贝拷贝的是指针。
B、深拷贝和浅拷贝最大的区别就是子类对象的地址是否改变。
C、深拷贝是对对象本身复制,但是不对对象的属性进行复制。
D、如果子类对象的地址改变那么就是深拷贝。

15、
很多内置类如UITableViewController的delegate属性都是assign而不是retain,这是为了:
答案:(D)
A、防止造成内存泄露
B、防止出现野指针
C、防止出现过度释放
D、防止循环引用

16、
关于OC内存管理方面说法错误的是:
答案:(B)
A、OC中的内存管理采用引用计数机制
B、autorelease pool 是OC中一种自动的垃圾回收机制
C、alloc、new或copy来创建一个对象,那么你必须调用release或autorelease
D、OC的内存管理机制本质上还是C语言中的手动管理方式,只不过稍加了一些自动方法

17、
关于系统自带的UITableViewCell,以下说法正确的是:
答案:(D)
A、Cell基本组成:编辑、内容、辅助
B、编辑:editView。tableView被编辑时显示
C、内容:contentView。包含imageView,textField等
D、accessoryView。显示cell的辅助信息

18、
应用程序启动顺序正确的是:①在UIApplication代理实例中重写启动方 法,设置第一个ViewController②程序入口main函数创建UIApplication实例和UIApplication代理实例③在第一个 ViewController中添加控件,实现对应的程序界面。
答案:(B)
A、①②③
B、②①③
C、①③②
D、③①②

19、
实现一个生成Student实例对象的便利构造器的正确写法是:
答案:(A)
A、
+ (id)studentWithName:(NSString *)newName andAge:(int)newAge
{
  Student *stu = [[[Student alloc] initWithName:newName andAge:newAge] autorelease];
  return stu;
}

B、
- (id)studentWithName:(NSString *)newName andAge:(int)newAge
{
  Student *stu = [[Student alloc] initWithName:newName andAge:newAge];
  return [stu autorelease];
}

C、
- (void)studentWithName:(NSString *)newName andAge:(int)newAge
{
  Student *stu = [[Student alloc] initWithName:newName andAge:newAge];
  return [stu autorelease];
}

D、
+ (void)studentWithName:(NSString *)newName andAge:(int)newAge
{
  Student *stu = [[Student alloc] initWithName:newName andAge:newAge];
  return [stu autorelease];
}


20、
以下关于视图的frame与bounds的理解错误的是:
答案:(A)
A、bounds是指这个view在window坐标系的坐标和大小
B、frame指的是这个view在它superview的坐标系的坐标和大小
C、frame和bounds是UIView中的两个属性(property)。
D、一个是以自身左上角的店为原点的坐标系,一个是以屏幕左上角的点为原点的坐标系。

21、
UITableView重用机制中,会将重用的cell放到哪种类型的集合中。
答案:(B)
A、NSMutableArray
B、NSMutableSet
C、NSDictionary
D、NSMutableDictionary

22、
当应用程序将要进入非活动状态执行,在此期间,应用程序不接收消息或事件,比如来电话了,此时会先执行以下哪个方法:
答案:(D)
A、- (void)applicationDidBecomeActive:(UIApplication *)application{ }
B、- (void)applicationDidEnterBackground:(UIApplication *)application{ }
C、- (void)applicationWillTerminate:(UIApplication *)application{ }
D、- (void)applicationWillResignActive:(UIApplication *)application{ }

23、
以下哪个控件不是继承于UIControl
答案:(D)
A、UIButton
B、UITextField
C、UISlider
D、UITextView

24、
对于UISegmentedControl,实现在指定索引插入一个选项并设置图片的方法是:
答案:(B)
A、[segmentedControl setImage:[UIImage imageNamed:@"btn_jyy.png"] forSegmentAtIndex:3];
B、[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"mei.png"] atIndex:2 animated:NO];
C、[segmentedControl insertSegmentWithTitle:@"insert" atIndex:3 animated:NO];
D、[[UIImageViewalloc]initWithImage:[segmentedControl imageForSegmentAtIndex:1]];

25、
对于UIScrollViewController,监控目前滚动的位置的属性是:
答案:(A)
A、contentOffSet
B、contentSize
C、contentInset
D、scrollIndicatorInsets

※ 判断题(共5题,每题3分)

1、
UISlider、UISwitch、UITextField这些类都继承于UIControl这个类。
答案:(T)
正确
错误

2、
[segmentedControl titleForSegmentAtIndex: ]表示指定索引文字的选项。
答案:(T)
正确
错误

3、
[self.view popToViewController: animated: YES];表示弹出一个视图控制器,到指定视图控制器上。
答案:(F)
正确
错误

4、
[textField resignFirstResponder]; 表示让文本输入框成为第一响应者, 弹出键盘进入编辑模式。
答案:(F)
正确
错误

5、
numberOfTapsRequired这个方法能获取到的是有几只手指点击。
答案:(F)
正确
错误

猜你喜欢

转载自2594082lhj.iteye.com/blog/2247203