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;
}