項(xiàng)目筆記

uisearchContorller 展示跑出屏幕

  self.definesPresentationContext = YES;

edgesForExtendedLayout屬性

只適用于集成了邊界容器的 controller,例如UINavigationController。

Layout Feedback Loop Debugging

1.(記錄每一個(gè)調(diào)用了setNeedsLayout的信息)
-UIViewLayoutFeedbackLoopDebuggingThreshold 100 // 50...1000
-NSViewLayoutFeedbackLoopDebuggingThreshold 100 // 50...1000
2.打全局的異常斷點(diǎn)exception break point。
po [_UIViewLayoutFeedbackLoopDebugger layoutFeedbackLoopDebugger]

根據(jù)地址查找問(wèn)題

Edit Scheme,切換到Tab Aguments 配置環(huán)境變量
MallocStackLoggingNoCompact
NSZombieEnabled
MallocStackLogging
shell malloc_history 40888 0x6497860 |grep 0x6497860
打開(kāi)“活動(dòng)監(jiān)視器”,在進(jìn)程列表中找到測(cè)試APP對(duì)應(yīng)的進(jìn)程號(hào)PID
Xcode啟用調(diào)試后會(huì)在進(jìn)程列表中找到對(duì)應(yīng)APP的進(jìn)程)
終端輸入sudo malloc_history PID 內(nèi)存地址

swift宏

#if TARGET_INTERFACE_BUILDER
@IBOutlet open weak var dataSource: AnyObject?
 @IBOutlet open weak var delegate: AnyObject?
#else
 open weak var dataSource: FSPagerViewDataSource?
 open weak var delegate: FSPagerViewDelegate?
#endif

swift xib 讀取

     let bundle = NSBundle(forClass: self.dynamicType)
     let nib = UINib(nibName: String(XXX), bundle: bundle)
  1.  #if TARGET_INTERFACE_BUILDER
     NSBundle *bundle = [NSBundle bundleForClass:[self class]];
     [bundle loadNibNamed:@“XXX” owner:self options:nil];
    #else
     [[NSBundle mainBundle] loadNibNamed:@“XXX” owner:selfoptions:nil];
     #endif
    

差別

initWithNibName方法:是延遲加載,這個(gè)View上的控件是 nil 的,只有到需要顯示時(shí),才會(huì)不是 nil。
loadNibNamed是立即加載,調(diào)用這個(gè)方法加載的xib對(duì)象中的各個(gè)元素都已經(jīng)存在.

pod兼容swift3.0

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '3.0'
    end
  end
end

便利執(zhí)行移除操作

[makeObjectsPerformSelector: removeFromSuperView]

編譯源文件

clang -rewrite-objc xxx.m

類和分類中l(wèi)oad的加載機(jī)制

1)、類load中可以調(diào)用分類的方法,因?yàn)楦郊觕ategory到類的工作會(huì)先于+load方法的執(zhí)行
2)、+load的執(zhí)行順序是先類,后category,而category的+load執(zhí)行順序是根據(jù)編譯順序決定的。

iOS9 HTTP 不能正常使用的解決辦法

在Info.plist中添加NSAppTransportSecurity類型Dictionary。
在NSAppTransportSecurity下添加NSAllowsArbitraryLoads類型Boolean,值設(shè)為YES

文字 圖片的不同

文字,顏色等是矢量數(shù)據(jù),放大不會(huì)失真。
圖片并非矢量數(shù)據(jù),處理方式有所不同

__block 原理

自動(dòng)變量是以值傳遞方式傳遞到Block的構(gòu)造函數(shù)里面去的
在Block中改變變量值有2種方式

 1. 一是傳遞內(nèi)存地址指針到Block中,
 2. 二是改變存儲(chǔ)區(qū)方式(__block)。

ARC環(huán)境下,一旦Block賦值就會(huì)觸發(fā)copy,__block就會(huì)copy到堆上

彈簧動(dòng)畫(huà)

 usingSpringWithDamping 0-1 數(shù)值越小「彈簧」的振動(dòng)效果越明
 initialSpringVelocity則表示初始的速度 數(shù)值越大一開(kāi)始移動(dòng)越快
[UIView animateWithDuration:0.8 delay:_delay usingSpringWithDamping:0.6 initialSpringVelocity:0.1  options:UIViewAnimationOptionCurveEaseInOut animations:^{
} completion:^(BOOL finished) {        
}];

搜索約束沖突視圖

(lldb) po [[UIWindow keyWindow] _autolayoutTrace]可以看到AutoLayout的層級(jí)圖

等待網(wǎng)絡(luò)回調(diào)

  dispatch_semaphore_t semaphore = dispatch_semaphore_create(1);
    [[HttpManager sharedInstance] requestWithParam:@{} success:^{
         dispatch_semaphore_signal(semaphore);
    } failed:^(NSString *errorMsg) {
        dispatch_semaphore_signal(semaphore);
    }];
    dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);

多網(wǎng)絡(luò)同時(shí)回調(diào) 線程同步

1.GCD 2.NSOperation 依賴 3.RAC

 // 創(chuàng)建
 dispatch_group_t group = dispatch_group_create();
 //  banner 接口
 dispatch_group_enter(group);
 [[BHNetReqManager sharedManager].bh_requestUrl(@"banner") startRequestWithCompleteHandler:^(id response, NSError *error) {
  dispatch_group_leave(group);
 }];
 //  table 接口
 dispatch_group_enter(group);
 [[HTTPManager sharedManager].requestUrl(@"table") startRequestWithCompleteHandler:^(id response, NSError *error) {
  dispatch_group_leave(group);
 }];
 dispatch_group_notify(group, dispatch_get_main_queue(), ^{
        // 處理數(shù)據(jù)
    });

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

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容