ios
清醒思考
有问题可以私信我.
展开
-
UITabelView实现HeaderSection不悬浮
【代码】UITabelView实现HeaderSection不悬浮。原创 2023-02-07 11:20:02 · 555 阅读 · 1 评论 -
解决iOS Retina屏幕0.5pt线宽颜色失真问题
【代码】解决iOS Retina屏幕0.5pt线宽颜色失真问题。原创 2022-12-03 23:45:53 · 334 阅读 · 0 评论 -
解决iOS Retina屏幕0.5pt线宽颜色失真问题
【代码】解决iOS Retina屏幕0.5pt线宽颜色失真问题。原创 2022-11-05 16:26:00 · 332 阅读 · 0 评论 -
清理所有NSUserdefault数据
【代码】清理所有NSUserdefault数据。原创 2022-09-06 12:33:04 · 776 阅读 · 0 评论 -
ios统计方法耗时
【代码】ios统计方法耗时。原创 2022-08-29 18:39:58 · 638 阅读 · 0 评论 -
CFHTTPMessageRef to NSDictionary
NSDictionary *headFields = CFBridgingRelease(CFHTTPMessageCopyAllHeaderFields(webSocket.receivedHTTPHeaders));原创 2022-08-24 21:43:53 · 879 阅读 · 0 评论 -
Multiple commands produce ‘.../xxx.app/Assets.car‘问题
私有库使用Images.xcassets会出现Assets.car生成多次导致冲突的问题.在Podfile文件添加。原创 2022-07-25 14:30:28 · 728 阅读 · 0 评论 -
ios判断当前线程是否是主线程
ios判断当前线程是否是主线程BOOL isMainThreadB = [[NSThread currentThread] isMainThread];原创 2022-05-23 18:14:40 · 1087 阅读 · 0 评论 -
xcode无法分屏问题
xcode无法分屏问题View -> Editor -> Hide Focus原创 2022-05-18 19:49:41 · 394 阅读 · 0 评论 -
navigationBarHidden导致返回手势失效的问题
navigationBarHidden导致返回手势失效的问题返回手势失效:self.navigationController.navigationBarHidden = YES;改成:self.navigationController.navigationBar.hidden = YES;就正常了, 很诡异.原创 2022-05-10 17:46:33 · 393 阅读 · 0 评论 -
ios获取当前方法的调用者
ios获取当前方法的调用者NSArray *syms = [NSThread callStackSymbols];NSLog(@"debug: caller: %@ ", [syms objectAtIndex:1]);原创 2022-05-05 10:01:29 · 732 阅读 · 0 评论 -
ios全局隐藏键盘
ios全局隐藏键盘[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];原创 2022-04-27 23:09:38 · 392 阅读 · 0 评论 -
创建只有上下或者左右手势的UIPanGestureRecognizer
创建只有上下或者左右手势的UIPanGestureRecognizerPanGesture.h#import <UIKit/UIKit.h>NS_ASSUME_NONNULL_BEGINtypedef NS_ENUM(NSInteger, PanDirection) { PanDirectionVertical, PanDirectionHorizontal,};@interface PanGesture : UIPanGestureRecognizer原创 2022-04-18 12:22:48 · 419 阅读 · 0 评论 -
WKWebView添加header
WKWebView添加headerNSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestReloadRevalidatingCacheData原创 2022-04-08 16:20:39 · 1010 阅读 · 0 评论 -
UITextfield移动光标到行尾
UITextfield移动光标到行尾UITextPosition *position = [textField endOfDocument];textField.selectedTextRange = [textField textRangeFromPosition:position toPosition:position];原创 2022-04-03 21:59:34 · 1287 阅读 · 0 评论 -
解决UILabel自动换行问题
解决UILabel自动换行问题设置:// 不以单词换行label.lineBreakMode = NSLineBreakByCharWrapping;原创 2022-03-30 11:58:25 · 1391 阅读 · 0 评论 -
xcode M1模拟器 报错
xcode M1模拟器 报错运行报错:1.building for iOS Simulator, but linking in object file built for iOS, for architecture arm642.The linked framework ‘Pods.framework’ is missing one or more architectures required by this target: arm64解决:1.Build Settings更改:2.podf原创 2022-03-15 22:46:49 · 4270 阅读 · 0 评论 -
ios关联对象给UIView添加tapBlock
ios关联对象给UIView添加tapBlock#import "UIView+tap.h"#import <objc/runtime.h>static char kActionHandlerTapGestureKey;static char kActionHandlerTapBlockKey;@implementation UIView (tap)- (void)setTapWithBlock:(void(^)(void))block { UITapGestureRe原创 2022-02-17 17:27:32 · 1277 阅读 · 0 评论 -
ios获取类定义
ios获取类定义- (void)viewDidLoad { [super viewDidLoad]; // ios获取类定义 int numClasses; Class *classes = NULL; numClasses = objc_getClassList(NULL, 0); if (numClasses > 0) { classes = malloc(sizeof(Class) * numClasses); n原创 2022-02-17 00:09:51 · 145 阅读 · 0 评论 -
ios动态创建对象
ios动态创建对象- (void)viewDidLoad { [super viewDidLoad]; // 动态创建对象 id theObject = class_createInstance(NSString.class, sizeof(unsigned)); id str1 = [theObject init]; NSLog(@"%@", [str1 class]); id str2 = [[NSString alloc] initWithString原创 2022-02-17 00:04:01 · 1391 阅读 · 0 评论 -
ios类和对象操作函数
ios类和对象操作函数MyClass.h@interface MyClass : NSObject<NSCopying, NSCoding>@property (nonatomic, strong) NSArray *array;@property (nonatomic, copy) NSString *string;- (void)method1;- (void)method2;+ (void)classMethod1;@endMyClass.m@interface原创 2022-02-16 23:58:45 · 651 阅读 · 0 评论 -
meta class调试
meta class调试meta class是一个类对象的类,当向对象发消息,runtime会在这个对象所属类方法列表中查找发送消息对应的方法,但当向类发送消息时,runtime就会在这个类的meta class方法列表里查找。所有的meta class,包括Root class,Superclass,Subclass的isa都指向Root class的meta class,这样能够形成一个闭环。#import "ViewController.h"#import <objc/runtime.h&原创 2022-02-16 23:10:11 · 576 阅读 · 0 评论 -
xcode清理控制台信息
xcode清理控制台信息command + k(竟然这么久才发现, 以前都是用鼠标点击清除????)原创 2022-02-09 11:19:50 · 606 阅读 · 0 评论 -
UIScrollView 拖拽滑动时收起键盘
UIScrollView 拖拽滑动时收起键盘// 方法1- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { [[[UIApplication sharedApplication] keyWindow] endEditing:YES];}// 方法2self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;...原创 2022-02-01 10:45:59 · 1600 阅读 · 0 评论 -
如何快速定位哪个 View 出现了约束警告
如何快速定位哪个 View 出现了约束警告点击xcode的Debuy View Hierarchy, 然后把出错内存地址贴到右边底部搜索栏, 就可以定位到是具体那个view了.原创 2022-02-01 10:05:03 · 1487 阅读 · 0 评论 -
ios千分位和小数精度位数处理
ios千分位和小数精度位数处理- (NSString *)formatDecimalNumber:(NSString *)string { if (!string || string.length == 0) { return string; } NSNumber *number = @([string doubleValue]); NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]原创 2022-01-31 21:39:07 · 733 阅读 · 0 评论 -
NSArray去重
NSArray去重NSArray *distinctArray = [[NSSet setWithArray:array] allObjects];原创 2022-01-20 12:08:04 · 1747 阅读 · 0 评论 -
解决M1pro cocoapods install 失败
解决M1pro cocoapods install 失败sudo arch -x86_64 gem install ffiarch -x86_64 pod install原创 2021-12-07 08:52:38 · 560 阅读 · 0 评论 -
NSDate compare
if ([date1 compare:date2] == NSOrderedDescending) { NSLog(@"date1 is later than date2");} else if ([date1 compare:date2] == NSOrderedAscending) { NSLog(@"date1 is earlier than date2");} else { NSLog(@"dates are the same");}原创 2021-11-23 08:17:34 · 1409 阅读 · 0 评论 -
ios画虚线
- (UIImage *)drawLineOfDashByImageView:(UIImageView *)imageView color:(UIColor *)color { UIGraphicsBeginImageContext(imageView.frame.size); [imageView.image drawInRect:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)];原创 2021-10-22 12:36:08 · 298 阅读 · 0 评论 -
NSArray截断
NSArray截断array = [array subarrayWithRange:NSMakeRange(0, 10)];原创 2021-10-12 17:59:18 · 223 阅读 · 0 评论 -
NSArray倒序
NSArray倒序array = [[array reverseObjectEnumerator] allObjects];原创 2021-10-12 17:24:44 · 363 阅读 · 0 评论 -
ios15UITableView分组高度异常
ios15UITableView分组高度异常if (@available(iOS 15.0, *)) { _tableView.sectionHeaderTopPadding = 0;}全局设置if (@available(iOS 15.0, *)) { [UITableView appearance].sectionHeaderTopPadding = 0;}原创 2021-09-24 16:56:01 · 441 阅读 · 0 评论 -
xcode打开卡死
xcode打开卡死1.打开终端:cd ~/Library/Autosave\ Information/2.删除下面的文件:rm -rf Unsaved\ Xcode*3.然后重新打开xcode就正常了。原创 2021-08-30 15:46:39 · 1382 阅读 · 0 评论 -
判断是否东八区
判断是否东八区NSString *zoneName = [NSString stringWithFormat:@"%@", [NSTimeZone systemTimeZone]];BOOL isEastEightZone = ([zoneName rangeOfString:@"+8"].location != NSNotFound);原创 2021-08-30 11:33:54 · 230 阅读 · 0 评论 -
报错:NSLayoutConstraintNumberExceedsLimit
报错:NSLayoutConstraintNumberExceedsLimitadd this:_NSLayoutConstraintNumberExceedsLimit原创 2021-08-17 12:28:44 · 140 阅读 · 0 评论 -
报错: but you still need to add “remote-notification“ to the list of your supported UIBackgroundModes
报错: but you still need to add “remote-notification” to the list of your supported UIBackgroundModesadd this:原创 2021-08-17 11:39:37 · 755 阅读 · 0 评论 -
报错: Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099
报错: Synchronous remote object proxy returned error: Error Domain=NSCocoaErrorDomain Code=4099问题原因:模拟器的默认设置了开启子系统com.apple.CoreTelephony的日志记录.解决方法:xcrun simctl spawn booted log config --mode "level:off" --subsystem com.apple.CoreTelephony...原创 2021-08-17 11:36:24 · 1170 阅读 · 0 评论 -
swift获取bundleid
swift获取bundleidBundle.main.bundleIdentifier原创 2021-08-16 15:17:51 · 1407 阅读 · 0 评论 -
cocoapods-packager生成framework和.a文件
cocoapods-packager生成framework和.a文件// 打包静态frameworkpod package xxx.podspec --force --no-mangle --embedded// 打包静态.apod package xxx.podspec --library --force//强制覆盖之前已经生成过的二进制库 --force//生成静态.framework --embedded//生成静态.a --library//生成动态.framework原创 2021-08-13 00:32:34 · 590 阅读 · 0 评论