//注意: NSDictionary * homeworkDic; if ([[dict valueForKeyPath:@"data.homework"] isKindOfClass:[NSDictionary class]]) { homeworkDic = [dict valueForKeyPath:@"data.homework"]; }else { homeworkDic = [self dictionaryWithJsonString:[dict valueForKeyPath:@"data.homework"]]; }
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { // 求出標題按鈕的索引 NSUInteger index = scrollView.contentOffset.x / scrollView.width; // index == [0, 4] // 點擊對應的標題按鈕 HKTitleButton *titleButton = self.titlesView.subviews[index]; //HKTitleButton *titleButton = [self.titlesView viewWithTag:index]; //此代碼 索引爲0時會報錯(viewWithTag 遞歸查找,包括本身 先查找本身的tag,再查找子視圖的tag,父視圖默認tag爲0,找到的是UIView而不是Button,因此setSelected方法找不到) [self titleButtonClick:titleButton]; }
1.在工程的AppDelegate文件中 @property (nonatomic, unsafe_unretained) UIBackgroundTaskIdentifier taskId; 2.在AppDelegate中的- (void)applicationDidEnterBackground:(UIApplication *)application 方法中 self.taskId =[application beginBackgroundTaskWithExpirationHandler] 用完的時候調用endTask 3.模擬一個長時間的任務 4.後臺任務結束的時候要釋放定時器
if (![array isKindOfClass:[NSNull class]] && array.count > 0 && array != nil) { }
數據源數組中包含空數組,怎麼移除?ios
if ([self.dataArray containsObject:@[]]) { [self.dataArray removeObject:@[]]; }
在一個UIView設置它的Frame的寬度是屏幕的兩倍,而後把登陸的View和註冊的View同時加載這個View上(註冊View.x=這個View寬度的一半),點擊切換按鈕時改變這個UIView的leadingConstraint(View.x)就可讓這兩個View顯示。json
iOS11 HTTP load failed (error code: -999)api
// 1.設置非校驗證書模式 _sessionManager.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone]; _sessionManager.securityPolicy.allowInvalidCertificates = YES; [_sessionManager.securityPolicy setValidatesDomainName:NO];
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // 禁用返回手勢 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; } } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; // 開啓返回手勢 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = YES; } }
[[UIApplication sharedApplication] performSelector:@selector(suspend)];數組
self.navigationController.hidesBarsOnSwipe = YES;緩存
ld: library not found for -lAFNetworking 這個錯誤是說編譯時找不到AFNetworking這個連接庫,可是我在項目代碼中找到對引用的地方,沒有其餘異常。網絡
若是不出所料,你應該能發現有一到數個的條目是用紅色字體來顯示的。
說明這些被工程引用的這些文件,其物理文件已經不處於以前所記錄的地方了。
這種狀況下,右鍵點擊紅色條目,選擇 「Reveal in Project Navigator」,
此時大抵能在左側欄中定位到缺失文件所在的路徑,接下來就好辦了,找到缺失的文件,挪回它應該待的地方。session
原本看到這兩種方法時以爲第一種應該就能解決了,由於報錯的信息看起來就像是原來的文件引用不到了而已,可是當我按照第一種方法去作時,發現「 Link binary With Libraries」 下沒有紅色的條目,並且原本就沒有AFNetworking這個條目,因此第一種方法不適用。第二種方法也不對,由於咱們的項目不少庫是經過pod管理的,AFNetworking也是pod管理的庫之一。這時候我就想起多是pod的緣由,在嘗試了pod update無果後,發現了第三種解決相似問題的方法。app
方法三:BuildSettings -> Other Linker Flags -> 去掉對應第三方庫的引用ide
方法四:關閉Xcode,在控制檯打開到工程目錄,用pod install 命令從新安裝,成功後再打開Xcode編譯項目。字體