iOS常用方法
来源:互联网 发布:filter 不过滤css js 编辑:程序博客网 时间:2024/06/09 14:22
https://developer.apple.com/
alertView:
UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"新建联系人" message:nil preferredStyle:UIAlertControllerStyleAlert];
UITextField * __block nameTextField;
UITextField * __block numTextField;
[alertC addTextFieldWithConfigurationHandler:^(UITextField *textField) {
nameTextField = textField;
}];
[alertC addTextFieldWithConfigurationHandler:^(UITextField *textField) {
numTextField = textField;
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
}];
UIAlertAction *addLinkman = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSDictionary *dic = @{@"name":nameTextField.text,@"num":numTextField.text};
[_linkmanList addObject:dic];
[self saveData];
[_tabView reloadData];
}];
[alertC addAction:cancelAction];
[alertC addAction:addLinkman];
[self presentViewController:alertC animated:YES completion:^{
}];
///不显示多余的cell线.
_tableView.tableFooterView = [[UIView alloc]init];
获取沙盒路径:
1: NSString *dbPath = [NSString stringWithFormat:@"%@/Documents/class.rdb",NSHomeDirectory()];
2: NSString *linkmanPath = [NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES)objectAtIndex:0];//获取沙盒路径
//补全中间路径
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:linkmanPath isDirectory:NULL]) {
[fileManager createDirectoryAtPath:linkmanPath withIntermediateDirectories:YES attributes:nil error:NULL];
}
linkmanPath = [NSString stringWithFormat:@"%@/linkman.plist",linkmanPath];
3: NSString *path = [[NSBundle mainBundle] pathForResource:@"baidu" ofType:@"html"];
NSData *data = [NSData dataWithContentsOfFile:path];
沙盒cache路径:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachesDir = [paths objectAtIndex:0];
AppDelegate 单例:
AppDelegate *myAppDelegate=[UIApplication sharedApplication].delegate;
手势:
UIPanGestureRecognizer * panGR=[[[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panGR:)] autorelease];
[_fImgV addGestureRecognizer:panGR];
_fImgV.userInteractionEnabled = YES;//imageView必须加这句
定义Block:
typedef void(^Change_Color)(UIColor *);
URL转码:
[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
定时器:
严格意义上讲 CADisplayLink 并不是计时器控件, 它是与显示器刷新频率一致的。比如显示的刷新频率是60赫兹, 那么 CADisplayLink 就会每秒钟执行60次。正是因为这个原因所以有时也把 CADisplayLink 当做计时器控件来使用。
if(theTimer == nil){
theTimer = [CADisplayLink displayLinkWithTarget:self selector:@selector(MyTask)];
theTimer.frameInterval = 2;
[theTimer addToRunLoop: [NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
//停用
[theTimer invalidate];
theTimer = nil;
}
1,创建一个定时器
+ (NSTimer *)timerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)yesOrNo;
这种方式创建的NStimer需要和NSRunLoop配合使用,NSRunLoop是一种消息机制的处理模式。不推荐这种创建方法
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)yesOrNo;
1)暂停:
_timer.fireDate = [NSDate distantFuture];
2)继续:
_timer.fireDate = [NSDate distantPast];
动画:
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations NS_AVAILABLE_IOS(4_0);
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion NS_AVAILABLE_IOS(4_0);
alertView:
UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"新建联系人" message:nil preferredStyle:UIAlertControllerStyleAlert];
UITextField * __block nameTextField;
UITextField * __block numTextField;
[alertC addTextFieldWithConfigurationHandler:^(UITextField *textField) {
nameTextField = textField;
}];
[alertC addTextFieldWithConfigurationHandler:^(UITextField *textField) {
numTextField = textField;
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
}];
UIAlertAction *addLinkman = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSDictionary *dic = @{@"name":nameTextField.text,@"num":numTextField.text};
[_linkmanList addObject:dic];
[self saveData];
[_tabView reloadData];
}];
[alertC addAction:cancelAction];
[alertC addAction:addLinkman];
[self presentViewController:alertC animated:YES completion:^{
}];
///不显示多余的cell线.
_tableView.tableFooterView = [[UIView alloc]init];
获取沙盒路径:
1: NSString *dbPath = [NSString stringWithFormat:@"%@/Documents/class.rdb",NSHomeDirectory()];
2: NSString *linkmanPath = [NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES)objectAtIndex:0];//获取沙盒路径
//补全中间路径
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:linkmanPath isDirectory:NULL]) {
[fileManager createDirectoryAtPath:linkmanPath withIntermediateDirectories:YES attributes:nil error:NULL];
}
linkmanPath = [NSString stringWithFormat:@"%@/linkman.plist",linkmanPath];
3: NSString *path = [[NSBundle mainBundle] pathForResource:@"baidu" ofType:@"html"];
NSData *data = [NSData dataWithContentsOfFile:path];
沙盒cache路径:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachesDir = [paths objectAtIndex:0];
AppDelegate 单例:
AppDelegate *myAppDelegate=[UIApplication sharedApplication].delegate;
手势:
UIPanGestureRecognizer * panGR=[[[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panGR:)] autorelease];
[_fImgV addGestureRecognizer:panGR];
_fImgV.userInteractionEnabled = YES;//imageView必须加这句
定义Block:
typedef void(^Change_Color)(UIColor *);
URL转码:
[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
定时器:
严格意义上讲 CADisplayLink 并不是计时器控件, 它是与显示器刷新频率一致的。比如显示的刷新频率是60赫兹, 那么 CADisplayLink 就会每秒钟执行60次。正是因为这个原因所以有时也把 CADisplayLink 当做计时器控件来使用。
if(theTimer == nil){
theTimer = [CADisplayLink displayLinkWithTarget:self selector:@selector(MyTask)];
theTimer.frameInterval = 2;
[theTimer addToRunLoop: [NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
}
//停用
[theTimer invalidate];
theTimer = nil;
}
1,创建一个定时器
+ (NSTimer *)timerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)yesOrNo;
这种方式创建的NStimer需要和NSRunLoop配合使用,NSRunLoop是一种消息机制的处理模式。不推荐这种创建方法
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)yesOrNo;
1)暂停:
_timer.fireDate = [NSDate distantFuture];
2)继续:
_timer.fireDate = [NSDate distantPast];
动画:
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations NS_AVAILABLE_IOS(4_0);
+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion NS_AVAILABLE_IOS(4_0);
0 0
- ios常用加密方法
- 常用ios方法
- ios推送常用方法
- iOS常用数学方法
- IOS常用方法
- ios 常用方法
- IOS常用方法
- ios Label常用方法
- ios线程-常用方法
- iOS---常用方法总结
- iOS - NSString常用方法
- iOS常用方法
- iOS UIALertViewController常用方法
- IOS 字符串常用方法
- iOS GCD常用方法
- ios Label常用方法
- ios 常用方法
- iOS常用封装方法
- java中的Collection集合 List Set Map
- 几种常用的webservice客户端和spring集成的方法
- nginx+ffmpeg筹建rtmp转播rtsp流的flash服务器
- 寻找ios培训机构
- Linux根目录下的sys文件夹下的子目录
- iOS常用方法
- nib must contain exactly one top level object which must be a UITableViewCell instance
- IIS配置jquery ajax、 json,mp4文件支持
- Mac下打开eclipse 始终提示 你需要安装Java SE 6 Runtime
- Andriod界面设计适配和Android Studio中的资源
- ArrayAdapter
- MySQL批量SQL插入性能优化
- PCA降维浅析
- [转载]Spring/Hibernate 应用性能优化的7种方法