![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
iOS Tips
Leon爱代码
这个作者很懒,什么都没留下…
展开
-
NSString字符串截取
1.截取字符串一部分 (substringWithRange:(NSRange*))NSString *a =@"01234567890";NSString *b = [a substringWithRange:NSMakeRange(0,2)];b = "01"2.字符串截取到第n位 (substringToIndex: n原创 2016-04-11 21:14:36 · 398 阅读 · 0 评论 -
iOS 刷新某个Section或Cell
[cpp] view plain copy//一个section刷新 NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2]; [tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutoma转载 2016-07-14 12:12:56 · 623 阅读 · 0 评论 -
Keychain简单存储(不使用官方封装)
iOS的keychain服务提供了一种安全的保存私密信息(密码,序列号,证书等)的方式。每个ios程序都有一个独立的keychain存储。从ios 3.0开始,跨程序分享keychain变得可行。下面就使用keychain来实现存取用户名和密码。苹果已经有现成的类封装好了keychain,KeychainItemWrapper.h和KeychainItemWrapper.m文件,可转载 2016-06-17 17:41:01 · 436 阅读 · 0 评论 -
NSClassFromString
NSClassFromString是一个很有用的东西,尤其在进行iPhone toolchain的开发上。正常来说,id myObj = [[NSClassFromString(@"MySpecialClass") alloc] init];和id myObj = [[MySpecialClass alloc] init];是一样的。但是,如果你的程序中并不存在MySpecia转载 2016-07-04 11:53:10 · 254 阅读 · 0 评论 -
iOS UIImage渲染模式 imageWithRenderingMode:
设置UIImage的渲染模式:UIImage.renderingMode着色(Tint Color)是iOS7界面中的一个设置UIImage的渲染模式,你可以设置一个UIImage在渲染时是否使用当前视图的Tint Color。UIImage新增了一个只读属性:renderingMode,对应的还有一个新增方法:imageWithRenderingMode:,它使用UIImageRende转载 2016-07-04 15:51:12 · 463 阅读 · 0 评论 -
iOS navigationController颜色透明问题
navigationBar的属性在iOS6.0之前默认为NO,之后默认为YES,因此会造成颜色有透明效果,和原本我们希望的颜色不同,需要手动改为NOself.navigationController.navigationBar.translucent原创 2016-07-04 19:08:59 · 1196 阅读 · 0 评论 -
判断iPhone型号
[objc] view plain copy #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) #define I转载 2016-06-20 10:44:42 · 277 阅读 · 0 评论 -
iOS 给文字上面加贯穿横线
在iOS开发中,我们可能会想要这种效果,尤其是商品售价上面:Snip20160513_8.png那么问题来了,这种效果是怎么实现的呢? 废话不多说,上代码!! UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(20, 50, 200, 50)]; [self.view addSubview:lab转载 2016-07-06 12:08:40 · 5459 阅读 · 0 评论 -
iOS UITextField PlaceHolder颜色
KVC轻松搞定:[textField setValue:CustomColor(173,173, 173) forKeyPath:@"_placeholderLabel.textColor"];[textField setValue:[UIFontsystemFontOfSize:16]forKeyPath:@"_placeholderLabel.tex原创 2016-07-29 10:08:58 · 276 阅读 · 0 评论 -
iOS中URL的encode和decode
1.URL编码NSString *encodeURL = [urlstringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];2.URL解码NSString *decodeURL = [urlstringByReplacingPercentEscapesUsingEncoding:NSUTF原创 2016-06-22 15:38:31 · 10256 阅读 · 0 评论 -
关于AFHTTPRequestOperationManager跟AFURLSessionManager的区别
AFNetworking的作者kylef在回答这个问题时如此说道:AFHTTPRequestOperationManager uses NSOperation’s under the hood, and it uses the older NSURLConnection API from Apple. It works on iOS 6 and onwards. AFURLSess转载 2016-08-09 10:04:32 · 1432 阅读 · 0 评论 -
禁止输入表情
第三方输入法不适用([textField.textInputMode.primaryLanguageisEqualToString:@"emoji"] || !textField.textInputMode.primaryLanguage)原创 2016-10-19 12:33:46 · 349 阅读 · 0 评论 -
iOS UIScrollView上使用Masonry
UIScrollview上使用自动约束需要注意scrollview的contentSize需要根据约束来确定,就算已经设定contentSize大小,因此scrollview上的子控件需要设置约束来保证scrollview可以确定contentSize大小。这有点像UITableView讲cell的高度设置成UITableViewAutomaticDimensions时需要设置约束保证cell的高原创 2017-01-14 13:51:47 · 1052 阅读 · 0 评论 -
每周本地推送
本地推送的时间间隔为每周时repeatInterval应该设置为NSCalendarUnitWeekdayOrdinal原创 2017-07-14 14:41:14 · 203 阅读 · 0 评论 -
UITableview Plain风格下 SectionHeader悬浮问题
在UITableview Plain风格下 SectionHeader在滑动时会始终悬浮在tableview上方,解决办法:- (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (scrollView ==self.contentTableView) {原创 2016-07-25 10:36:18 · 2923 阅读 · 0 评论 -
iOS9 HTTP 不能正常使用的解决办法
iOS 9 (may) force developers to use App Transport Security exclusively. I overheard this somewhere randomly so I don't know whether this is true myself. But I suspect it and have come to this conclusi转载 2016-07-01 16:18:40 · 207 阅读 · 0 评论 -
NavigationContorller跳转问题
1. 跳转返回根目录1[self.navigationController popToRootViewController]2. 跳转到指定页面的两种方法(1)通过index指针[self.navigationController popToViewController:[self.navi原创 2016-05-11 10:50:04 · 297 阅读 · 0 评论 -
UILabel大小问题
1.Lable随字体自动调整宽高[self.label sizeToFit];原创 2016-05-25 16:27:05 · 212 阅读 · 0 评论 -
iOS导航栏跳转和modal跳转
1. 在临时页面,比如临时选项,说明页之类的附属页面使用modal跳转方式。2.modal跳转有四个动画效果:UIModalTransitionStyleCoverVertical 默认底部滑入UIModalTransitionStyleFlipHorizontal 水平翻转进入UIModalTransitionStyleCrossDissolve 交叉溶解UIModalTra原创 2016-05-13 09:29:42 · 518 阅读 · 0 评论 -
Masonry介绍与使用实践(快速上手Autolayout)
前言1MagicNumber -> autoresizingMask -> autolayout以上是纯手写代码所经历的关于页面布局的三个时期在iphone1-iphone3gs时代 window的size固定为(320,480) 我们只需要简单计算一下相对位置就好了在iphone4-iphone4s时代 苹果转载 2016-05-06 10:46:03 · 235 阅读 · 0 评论 -
UIButton Tips
1. setBackgroundImage 和 setImage 方法的区别:setBackgroundImage方法设置的图片会随着按键大小自动适应,而setImage不会!!!!原创 2016-05-08 10:55:35 · 155 阅读 · 0 评论 -
iOS 截屏+裁剪
//截屏UIGraphicsBeginImageContextWithOptions(ScreenSize,NO, 2);[self.view.layerrenderInContext:UIGraphicsGetCurrentContext()];UIImage *image= UIGraphicsGetImageFromCurrentImageContex原创 2016-05-19 17:02:18 · 304 阅读 · 0 评论 -
NSDate相关
1.获取当天时间 NSDate *currentDate = [NSDatedate];2.获取第二天或第n天时间NSTimeInterval secondsPerDay = 24 * 60 *60;//获取n天前或n天后,改变TimeInterval数值NSDate *tomorrowDate = [currentDatedat原创 2016-05-23 14:23:58 · 167 阅读 · 0 评论 -
ISSUE:-fembed-bitcode is not supported on versions of iOS prior to 6.0
-fembed-bitcode is not supported on versions of iOS prior to 6.0 问题"Xcode 7 has a ENABLE_BITCODE option to embed bitcode in apps, app extensions, and frameworks. The option is turned on by defau原创 2016-06-29 16:19:33 · 594 阅读 · 0 评论 -
iOS UITextView相关
1.UITextView默认文字四周会有8 point的padding。2.改变行间距的方法:使用富文本。具体代码:NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStylealloc] init];paragraphStyle.lineSpacing =8;NSDictionary原创 2016-07-12 16:05:03 · 258 阅读 · 0 评论 -
iOS 富文本相关
1. 一段文字不同大小颜色NSMutableAttributedString *attributedString = [[NSMutableAttributedStringalloc] initWithString:@"AttributedString Test!"];[attributedString addAttribute:NSForegroundCo原创 2016-07-12 17:52:05 · 187 阅读 · 0 评论 -
iOS 横竖屏监听通知
iOS横竖屏通知有两种,一种监听设备横竖屏状态,另一种监听状态栏横竖屏状态。与布局有关一般使用第二种,因为如果一个viewcontroller不支持自动旋转,当设备由竖屏转横屏时依然会执行监听设备横竖屏的通知方法。1.监听设备横竖屏[[NSNotificationCenter defaultCenter] addObserver:self selector:@selec原创 2016-06-28 11:21:28 · 6793 阅读 · 0 评论 -
AFNetworking提示Invalid parameter not satisfying: URLString
URL中出现中文没有进行编码原创 2016-07-23 19:05:27 · 728 阅读 · 0 评论 -
CornerStone上传静态库(.a文件)
首先打开软件左上角 CornerStone-Preferences-SubVersion第一个地方把对号去掉,第二个地方把.a那个删除,然后save。然后把你的.a文件放到本地的相应文件夹下,但是 CornerStone(我的是v2.7.10 版本的) 里相应文件夹下看不到带问号的.a文件的话,点击上边 View-Show Ignored Items到这里就ok了转载 2016-07-01 16:14:40 · 176 阅读 · 0 评论 -
iOS11 Tableview顶部空白和Section Header留白问题
iOS11上废除了automaticallyAdjustsScrollViewInsets这个方法,所以造成iOS11机型顶端留白问题解决方法: if (@available(iOS 11.0, *)) { self.tableview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustment原创 2017-11-20 13:15:08 · 10761 阅读 · 1 评论