IOS開發筆記

1.使用定時器時,避免移動界面時,導致定時器暫停:

[[NSRunLoop currentRunLoop] addTimer: self.timer forMode:NSRunLoopCommonModes];

2.屏幕旋轉

?2.1阻止點擊要旋轉的視圖

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController*)viewController


2.1.在AppDelegate 中添加

- (UIInterfaceOrientationMask) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

if ([self.window.rootViewController isEqual: self.testVC]) { //要旋轉的跟控制器

return UIInterfaceOrientationMaskLandscapeLeft;

}

return UIInterfaceOrientationMaskPortrait;

}



3.關于Label刪除線問題

在iOS 10.3 以后系統的刪除線功能不能實現

if ([UIDevice currentDevice].systemVersion.floatValue >= 10.3f) {

UILabel * dLabel = [[UILabel alloc] init];

CGFloat width1=[(NSString *) label2.text sizeWithFont:[UIFont systemFontOfSize:13] constrainedToSize:CGSizeMake(label2.width,100)].width-8;

dLabel.center = CGPointMake(label2.width/2, label2.height/2);

dLabel.bounds = CGRectMake(0, 0, width1, 1);

dLabel.backgroundColor = [UIColor grayColor];

[label2 addSubview: dLabel];

} else {

NSAttributedString *attrStr = [[NSAttributedString alloc]initWithString: label2.text? attributes: @{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle|NSUnderlinePatternSolid)}];

label2.attributedText = attrStr;

}



最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容