iOS
文章平均质量分 50
ZZQCSN
这个作者很懒,什么都没留下…
展开
-
ios 11 定位权限增加仅在使用期间使用方法
1.在plist中增加NSLocationWhenInUseUsageDescription和NSLocationAlwaysAndWhenInUsageDescription,如果需要支持iOS10的话,增加NSLocationAlwaysUsageDescription。 2.框架下的CLLocationManager 把requestWhenInUseAuthor原创 2017-12-06 12:02:06 · 3558 阅读 · 0 评论 -
iOS沙盒机制
1.ios 沙盒机制iOS应用程序只能在为该改程序创建的文件系统中读取文件,不可以去其它地方访问,此区域被成为沙盒,所以所有的非代码文件都要保存在此,例如图像,图标,声音,映像,属性列表,文本文件等。 1.1、每个应用程序都有自己的存储空间 1.2、应用程序不能翻过自己的围墙去访问别的存储空间的内容 1.3、应用程序请求的数据都要通过权限检测,假如不符合条件的话,不会被转载 2016-03-16 11:04:44 · 383 阅读 · 0 评论 -
iOS 单选按钮
全局 的self.starButton- (void)click:(UIButton *)button{ if(button!=self.starButton){ self.starButton.selected=NO; self.starButton=button; } self.starButton.转载 2016-02-17 11:34:31 · 968 阅读 · 0 评论 -
UITextViewDelegate详解
1.//在text view获得焦点之前会调用textViewShouldBeginEditing: 方法。- (BOOL)textViewShouldBeginEditing:(UITextView *)textView;2.//当text view失去焦点之前会调用textViewShouldEndEditing- (BOOL)textViewShouldEndEditin翻译 2016-02-17 09:46:33 · 4277 阅读 · 0 评论 -
懒加载
- (UIButton *)clear{ if (!_clear) { _clear = [[UIButtonalloc]initWithFrame:CGRectMake(230,200, 120, 40)]; [_clearsetTitle:@"清除"forState:UIControlStateNormal];转载 2016-02-15 12:00:27 · 283 阅读 · 0 评论 -
tableviewcell添加多个按钮删除事件
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{ if (editingStyle ==UITableViewCellEditin转载 2016-02-15 11:30:43 · 499 阅读 · 0 评论 -
横向头像布局
@interface ViewController ()UITableViewDataSource,UITableViewDelegate>@property(nonatomic,strong)UITableView *tableView;@end@implementation ViewController- (void)viewDi转载 2016-02-15 11:26:32 · 860 阅读 · 0 评论 -
iOS去掉导航栏背景图片和底部线
//去掉背景图片 [self.navigationController.navigationBarsetBackgroundImage:[[UIImagealloc] init]forBarMetrics:UIBarMetricsDefault]; //去掉底部线条 [self.navigationController.navigationBa转载 2016-01-29 09:01:25 · 861 阅读 · 0 评论 -
iOS删除cell
1.删除section[DataArray removeObjectAtIndex:path.section]; [_AllTableView deleteSections:[[NSIndexSet alloc]initWithIndex:path.section] withRowAnimation:UITableViewRowAnimationFad转载 2016-01-28 20:17:57 · 406 阅读 · 0 评论 -
设置textView的行间距
1.如果只是静态显示textView的内容为设置的行间距,执行如下代码:// textview 改变字体的行间距 NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.lineSpacing = 10;// 字体的行间距转载 2015-12-07 15:34:43 · 449 阅读 · 0 评论 -
ios 防止按钮快速点击造成多次响应的避免方法。
- (void) timeEnough{ UIButton *btn=(UIButton*)[self.view viewWithTag:33]; btn.selected=NO; [timer invalidate]; timer=nil; } - (void) btnDone:(UIButton*)btn {转载 2015-12-03 09:20:33 · 423 阅读 · 0 评论 -
ios:UIAlertView自动消失
法: (1)结合NSTimer 定义UIAlertView *baseAlert; - (void) performDismiss: (NSTimer *)timer { [baseAlert dismissWithClickedButtonIndex:0 animated:NO];//important [baseAlert release];转载 2015-12-01 17:26:47 · 287 阅读 · 0 评论 -
iOSUIBezierPath
1.创建贝塞尔曲线+ (UIBezierPath *)bezierPath;//创建UIBezierPath UIBezierPath *path = [UIBezierPath bezierPath];2.创建矩形+ (UIBezierPath *)bezierPathWithRect:(CGRect)rect;3.使用UIBezierPath转载 2016-02-17 14:41:33 · 535 阅读 · 0 评论 -
NSUserDefaults
#pragma mark - 1.存储本地数据+(void)AddLocalDataWithInformation:(NSString*)data andKey:(NSString*)key;#pragma mark - 2.删除本地数据+(void)DeleteLocalDataWithInformation:(NSString*)原创 2016-03-07 13:30:14 · 274 阅读 · 0 评论 -
自己用的一些宏定义
1。block防止循环引用#define WS(weakSelf) __unsafe_unretained __typeof(&*self)weakSelf = self;原创 2016-11-03 14:46:45 · 347 阅读 · 0 评论 -
导航栏透明度改变
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{ if (scrollView !=self.MyCollectionDetailsTable) { return; } UIColor *color=kUIColorFromRGBWithAlapha(232转载 2016-07-27 15:26:35 · 361 阅读 · 0 评论 -
UITABBAR特殊样式设置
[[UITabBar appearance] setShadowImage:[UIImage new]];- (void)setupTabBarBackgroundImage { UIImage *image = [UIImage imageNamed:@"tab_bg"]; CGFloat top = 40; // 顶端盖高度CGFloat bottom = 40 ; // 底端盖高度CGFlo转载 2016-07-22 17:08:29 · 370 阅读 · 0 评论 -
iOS 支付密文实现方案
#import @class WCLPassWordView;@protocol WCLPassWordViewDelegateNSObject>@optional/** * 监听输入的改变 */- (void)passWordDidChange:(WCLPassWordView *)passWord;转载 2016-06-13 09:30:00 · 582 阅读 · 0 评论 -
ios好玩的两个属性
通过IB_DESIGNABLE配合IBInspectable可以实现动态刷新IB_DESIGNABLE@interfaceIBDesigbableImageview : UIImageView@property(nonatomic) IBInspectable CGFloat cornerRadius;这两个属性配合使用可以在storyboard或者原创 2016-06-13 09:14:16 · 347 阅读 · 0 评论 -
将16进制转为 UIColor
+ (UIColor *) colorFromHexCode:(NSString *)hexString { NSString *cleanString = [hexStringstringByReplacingOccurrencesOfString:@"#"withString:@""]; if([cleanString length] == 3) {转载 2016-06-03 10:00:48 · 374 阅读 · 0 评论 -
PDF阅读器---UIDocumentInteractionController
UIDocumentInteractionController主要由两个功能,一个是文件预览,另一个就是调用iPhoneh里第三方相关的app打开文档(注意这里不是根据url scheme 进行识别,而是苹果的自动识别)原创 2016-05-26 09:02:55 · 395 阅读 · 0 评论 -
ios cell多选
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSArray *value = [selectValueDictionaryallKeys]; if ([valuecontainsObject:in转载 2016-03-13 21:24:43 · 393 阅读 · 0 评论 -
ios tableview单选
//设置默认选中 NSIndexPath*defaultIndexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [self tableView:self.tableView didSelectRowAtIndexPath:defaultIndexPath]; - (void)tableView:(UITableView转载 2016-03-13 21:17:19 · 361 阅读 · 0 评论 -
好玩的创建UI
1.创建控件_timeLabel = [UILabelnew];2.把控件放到数组里NSArray *views = @[_iconView, _nameLable, _contentLabel,_moreButton, _picContainerView,_timeLabel, _operationButton,_commentView];原创 2016-03-08 09:31:20 · 435 阅读 · 0 评论 -
协议代理的实现
基于我自定义的继承自UIImageView的一个CustomImageView;在.h文件中1,声明有这样一个协议:@protocol CustomImageViewDelegate;2,紧接着定义一个属性:@property (nonatomic, weak) iddelegate;3,在结尾处定义详细部分:@protocol Cu转载 2015-11-30 09:14:56 · 287 阅读 · 0 评论 -
IOS 应用 判断是否第一次启动
就是吧NSBundle 中的版本号和沙盒中的存储的版本号对比//此为找到plist文件中得版本号所对应的键 一般不知道这个健NSString *key = (NSString *)kCFBundleVersionKey;// 1.从plist中取出版本号NSString *version = [NSBundle mainBundle].infoDictionary[key];转载 2015-11-30 09:22:08 · 245 阅读 · 0 评论 -
iOS~block的使用
iOS中block比较常用,但是又和OC的语法显得有点格格不入,难于理解。以下是我个人初步的理解,供查阅。 1.block的声明 //声明一个blocktypedef NSString *(^WXYTestBlock)(NSString *name, int age);以上声明了一个名字叫做WXYTestBlock的block,参数为一个字符串类型的name和一转载 2015-11-30 09:32:33 · 265 阅读 · 0 评论 -
NSMotification通知使用方法
- (void)callBack{ NSLog(@"this is Notification.");}2. 定义通知:[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(cal转载 2015-11-26 17:00:07 · 282 阅读 · 0 评论 -
iOSMVC设计模式
M:模型例子://用户名@property(nonatomic,copy)NSString * username;//头像@property(nonatomic ,copy)NSString * imagePath;//时间@property(nonatomic,copy)NSString *time;//内容@pr原创 2015-11-26 16:26:03 · 326 阅读 · 0 评论 -
Label长按复制
#import "UICopy.h"@implementation UICopy/*// Only override drawRect: if you perform custom drawing.// An empty implementation adversely affects performance during animation转载 2015-11-26 16:21:48 · 504 阅读 · 1 评论 -
iOS按钮倒计时
#pragma mark---获取验证码///获取验证码-(void)startTime{ __block int timeout=59;//倒计时时间 dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0); dispat转载 2015-11-26 14:40:56 · 244 阅读 · 0 评论 -
UIButton图片文字位置调整
#import "ImageLeftBtn.h"@implementation ImageLeftBtn-(void)setTitleEdgeInsets:(UIEdgeInsets)titleEdgeInsets{ [selfsetTitleEdgeInsets:UIEdgeInsetsMake(5,10, 5, 10)];}-(vo原创 2015-11-26 16:23:04 · 311 阅读 · 0 评论 -
UIImageView长按保存相册
#import "UICopyImageView.h"#import "SVProgressHUD.h"@interface UICopyImageView ()UIAlertViewDelegate>@property (nonatomic,strong, readonly)UILongPressGestureRecognizer *longPressGestur翻译 2015-11-26 16:21:07 · 397 阅读 · 0 评论 -
UITabBar(拓展)
1.h#import @interface UITabBar (badge)- (void)showBadgeOnItemIndex:(int)index; //显示小红点- (void)hideBadgeOnItemIndex:(int)index;//隐藏小红点@end#import "UITabBar+badge.转载 2015-11-26 16:17:52 · 308 阅读 · 0 评论 -
NSDate(拓展)
#pragma mark - 1.NSString转NSDate(年,月,日分割)/** * 1.NSString转NSDate(年,月,日分割) * * @param uiDate 需要转换的日期 * * @return */+(NSDate*) convertDateFromString:(NSString*)uiDate{转载 2015-11-26 16:15:36 · 389 阅读 · 0 评论 -
iOS textfiled限制长度
staticconst NSInteger kMaxLength =15;[self.NickNameaddTarget:selfaction:@selector(textFieldChange)forControlEvents:UIControlEventEditingChanged];//限定主题字数 15个- (void)tex转载 2015-12-28 09:44:40 · 324 阅读 · 0 评论 -
IOS开发判断在字符串中是否包含相应的字符
123456789101112131415NSString *str1 = @"abcd"; NSString *str = @"a"; //在str1这个字符串中搜索\n,判断有没有 if转载 2015-11-26 19:24:55 · 503 阅读 · 0 评论 -
AVFoundation汉子转语音
#import #import @interface TXSoundPlayer :NSObject{ NSMutableDictionary* soundSet; //声音设置 NSString* path; //配置文件路径}@property(nonatomic,assign)float rate; //语速@pr转载 2015-11-26 16:31:32 · 388 阅读 · 0 评论 -
正计时
#pragma mark -- 设计时间定时器-(void)startTime{ __block int timeout=1;//倒计时时间 dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0); dispatch_source_原创 2015-11-26 18:06:34 · 592 阅读 · 0 评论 -
IOS开发限制UITextField只可以输入数字
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { return [self validateNumber:string];}- (BOOL)validateNumber:(NSStr转载 2015-11-26 18:32:30 · 413 阅读 · 0 评论