UI基礎--筆試題解析(含答案)


        1、以下對響應鏈說法錯誤的是:答案:(A)
        A、當事件發(fā)生的時候,響應鏈首先被發(fā)送給第一個響應者  //響應者鏈——檢測觸碰視圖 :觸碰屏幕->硬件檢測->UIApplication->window->viewController->view->檢測所有子試圖->最終確認觸碰位置.
        B、事件將沿著響應者鏈一直向下傳遞,直到被接受并作出處理
        C、如果整個過程都沒有響應這個事件,則該事件最終要由APP Delegate做出處理
        D、一般情況下,在響應鏈中只要有對象處理事件,事件就會被傳遞 // 傳遞給該對象后不再傳遞.

    2、以下對多線程開發(fā)的理解錯誤的是:答案:(C)
    A、發(fā)揮多核處理器的優(yōu)勢,并發(fā)執(zhí)行讓系統(tǒng)運行的更快、更流暢,用戶體驗更好
    B、多線程程序中,一個進程包含2個以上的線程(含2個)
    C、大量的線程降低代碼的可讀性,但不需要更多的內存空間 // 前半句正確,后半句錯,需要更多的內存空間
    D、當多個線程對同一個資源出現(xiàn)爭奪的時候要注意線程安全的問題

    3、實現(xiàn)一個生成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];
    }

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

    5、下面關于深拷貝與淺拷貝理解正確的是:答案:(A)
    A、深拷貝拷貝的是內容,淺拷貝拷貝的是指針。
    B、深拷貝和淺拷貝最大的區(qū)別就是子類對象的地址是否改變。
    C、深拷貝是對對象本身復制,但是不對對象的屬性進行復制。
    D、如果子類對象的地址改變那么就是深拷貝。

    6、關于OC內存管理方面說法錯誤的是:答案:(B)
    A、OC中的內存管理采用引用計數機制 // 內存釋放后并不是內存立即被干掉,而是沒有對象對它有持有權.
    B、autorelease pool 是OC中一種自動的垃圾回收機制 // 不是自動的回收.
    C、alloc、new或copy來創(chuàng)建一個對象,那么你必須調用release或autorelease
    D、OC的內存管理機制本質上還是C語言中的手動管理方式,只不過稍加了一些自動方法

    7、以下的代碼會出現(xiàn)什么問題:
    @implementation Person
    - (void)setAge:(int)newAge {
      self.age = newAge;
    }
    @end答案:(B)
    A、會造成循環(huán)引用
    B、會造成死循環(huán) // 該點語法本身是調用set語法,在set中調用set方法賦值,造成死循環(huán).
    C、會出現(xiàn)內存泄露
    D、會出現(xiàn)野指針

    8、對于UIScrollViewController,scrollView將開始降速時,執(zhí)行的方法是:答案:(D)
    A、- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;{ }// 開始拖拽
    B、- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;{ }// 已經減速完成,靜止了
    C、- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;{ }// 結束滾動
    D、- (void)scrollViewWillBeginDecelerating:

    9、以下哪個控件不是繼承于UIControl答案:(D)
    A、UIButton
    B、UITextField
    C、UISlider
    D、UITextView // UIScrollView的子類

    10、下面對UIView、UIWindow和CALayer理解錯誤的是:答案:(C)
    A、UIView繼承于UIResponder
    B、UIResponder繼承于NSObject,UIView可以響應用戶事件。
    C、UIResponder繼承與NSObject,CALayer繼承于NSObject,CALayer可以響應事件。//CALayer不響應事件,只繪制內容
    D、UIView是用來顯示內容的,可以處理用戶事件,CALayer是用來繪制內容的,依賴與UIView來進行顯示

    11、以下關于視圖的frame與bounds的理解錯誤的是:答案:(A)
    A、bounds是指這個view在window坐標系的坐標和大小 // frame和bounde詳解 http://www.itdecent.cn/p/c9494fb01678
    B、frame指的是這個view在它superview的坐標系的坐標和大小
    C、frame和bounds是UIView中的兩個屬性(property)。
    D、一個是以自身左上角的店為原點的坐標系,一個是以屏幕左上角的點為原點的坐標系。

    12、以下哪個方法在當程序將要退出時被調用,且通常在此方法里寫一些用來保存數據和一些退出前的清理工作。答案:(B)
    A、- (void)applicationExitsOnSuspend:(UIApplication *)application{ }
    B、- (void)applicationDidEnterBackground:(UIApplication *)application{ } // 程序進入后臺要執(zhí)行的方法,一般保存數據和清理在該方法中,雖然選項C是程序將要退出時被調用,但是數據保存和清理一般不在該方法中.
    C、- (void)applicationWillTerminate:(UIApplication *)application{ }
    D、- (void)applicationDidFinishLaunching:(UIApplication *)application{ }

    13、很多內置類如UITableViewController的delegate屬性都是assign而不是retain,這是為了:答案:(D)
    A、防止造成內存泄露
    B、防止出現(xiàn)野指針
    C、防止出現(xiàn)過度釋放
    D、防止循環(huán)引用

    14、以下不屬于ios中實現(xiàn)多線程的方法是:答案:(D)// 還有一種:NSObject 實現(xiàn)異步后臺執(zhí)行
    A、NSThread
    B、NSOperationQueue
    C、Grand Central Dispatch(GCD)
    D、NSURLRequest

    15、對于UISearchBar,要實現(xiàn)實時搜索(即搜索內容實時發(fā)生變化時),會執(zhí)行以下哪個方法:答案:(C)
    A、- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar;
    B、- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar;
    C、- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{ }
    D、- (void)searchBarResultsListButtonClicked:(UISearchBar *)searchBar{ } 

    16、以下關于導航欄外觀屬性對應的解釋錯誤的是:答案:(D)
    A、barStyle bar的樣式
    B、translucent bar的透明度
    C、backgroundImage bar的背景圖片
    D、barTintColor bar上控件的顏色 // bar本身的前端顏色

    17、當程序從后臺將要重新回到前臺的時候,會先執(zhí)行以下哪個方法:答案:(B)
    A、- (void)applicationDidFinishLaunching:(UIApplication*)application{ }// 應用程序加載完畢
    B、- (void)applicationWillEnterForeground:(UIApplication *)application{ } // 將要進入前臺
    C、- (void)applicationDidBecomeActive:(UIApplication *)application{ }
    D、 - (void)applicationWillTerminate:(UIApplication *)application{ }

    18、實現(xiàn)一個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  應該是 static 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;
    }

    19、當應用程序將要進入非活動狀態(tài)執(zhí)行,在此期間,應用程序不接收消息或事件,比如來電話了,此時會先執(zhí)行以下哪個方法:答案:(D)
    A、- (void)applicationDidBecomeActive:(UIApplication *)application{ }
    B、- (void)applicationDidEnterBackground:(UIApplication *)application{ }
    C、- (void)applicationWillTerminate:(UIApplication *)application{ }
    D、- (void)applicationWillResignActive:(UIApplication *)application{ }

    20、應用程序啟動順序正確的是:
    ①在UIApplication代理實例中重寫啟動方法,設置第一個ViewController
    ②程序入口main函數創(chuàng)建UIApplication實例和UIApplication代理實例
    ③在第一個ViewController中添加控件,實現(xiàn)對應的程序界面。 答案:(B)
    A、①②③
    B、②①③
    C、①③②
    D、③①②

    21、對于UICollectionViewController,實現(xiàn)定義每個元素的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();  
    }

    22、以下對于UIScrollView的屬性,說法錯誤的是:答案:(D)
    A、bounces 控制控件遇到邊框是否反彈
    B、pagingEnabled 控制控件是否整頁翻動
    C、scrollEnabled 控制控件是否能滾動
    D、contentInset 滾動范圍大小 // contentSize 才是滾動范圍大小

    23、對于UIScrollViewController,監(jiān)控目前滾動的位置的屬性是:答案:(A)
    A、contentOffSet // 偏移量
    B、contentSize
    C、contentInset
    D、scrollIndicatorInsets

    24、在MVC框架中,M與C通訊,通常使用什么方式?答案:(A)
    A、KVO與通知
    B、協(xié)議-代理 // C 和 V 
    C、類目 
    D、屬性

    25、對于UILabel,設置單詞折行方式的屬性是:答案:(B)
    A、textAlignment // 對齊方式
    B、lineBreakMode 
    C、numberOfLines
    D、sizeToFit // 自適應Size

    26、關于ViewController 的 alloc,loadView, viewDidLoad,viewWillAppear的調用,說法錯誤的是:答案:(C)
    A、alloc在初始化當前的ViewController時調用
    B、沒有正在使用nib視圖頁面,子類將會創(chuàng)建自己的自定義視圖層時調用loadView
    C、視圖將要加載完畢時,viewDidLoad被調用
    D、視圖即將出現(xiàn)的時候調用viewWillAppear

    27、關于系統(tǒng)自帶的UITableViewCell,以下說法正確的是:答案:(D)
    A、Cell基本組成:編輯、內容、輔助
    B、編輯:editView。tableView被編輯時顯示
    C、內容:contentView。包含imageView,textField等
    D、accessoryView。顯示cell的輔助信息

    28、UITableView重用機制中,會將重用的cell放到哪種類型的集合中。答案:(B)
    A、NSMutableArray
    B、NSMutableSet
    C、NSDictionary
    D、NSMutableDictionary

    1、UISlider、UISwitch、UITextField這些類都繼承于UIControl這個類。答案:(T)
    正確
    錯誤

    2、[textField resignFirstResponder]; 表示讓文本輸入框成為第一響應者, 彈出鍵盤進入編輯模式。答案:(F) // 取消第一響應者
    正確
    錯誤

    3、[self.view popToViewController: animated: YES];表示彈出一個視圖控制器,到指定視圖控制器上。答案:(F) // 返回(入棧出棧) 并沒有彈出
    正確
    錯誤

    4、numberOfTapsRequired這個方法能獲取到的是有幾只手指點擊。答案:(F)// 輕拍次數
    正確
    錯誤

    5、[segmentedControl titleForSegmentAtIndex: ]表示指定索引文字的選項。答案:(T)
    正確
    錯誤

附上一張繼承關系圖:

繼承關系.jpg

MVC:

MVC.jpg
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容