ios7基础
文章平均质量分 73
berained
这个作者很懒,什么都没留下…
展开
-
Gesture - Long Press
@property (nonatomic, strong) UIButton *dummyButton;@property (nonatomic, strong) UILongPressGestureRecognizer *longPressGesture;-(void)initButton { self.btn = [UIButton buttonWithT翻译 2014-01-21 10:23:28 · 747 阅读 · 0 评论 -
GCD-queue介绍
三种queue类型 Main queue : 主队列执行主线程,调用所有与UI相关的方法,使用dispatch_get_main_queue函数检索句柄主队列 Concurrent queues : 并发队列,执行异步或同步任务。使用dispatch_get_global_queue函数检索句柄并发队列。 Serial queues : 连续串行队列,不在翻译 2013-12-17 15:43:37 · 774 阅读 · 0 评论 -
Creat folders -创建文件夹
1。实现 - (BOOL)createDirectoryAtPath:(NSString *)pathwithIntermediateDirectories:(BOOL)createIntermediates attributes:(NSDictionary *)attributes error:(NSError **)errorcreateIntermediates:YES-若翻译 2014-01-24 17:04:03 · 989 阅读 · 0 评论 -
write to and read from files (读写文件)
1。路径 : NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"MyFile.txt"];2。写入文件:NSString : //带编码 - (BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAux翻译 2014-01-24 15:45:55 · 997 阅读 · 0 评论 -
delete Files and Folders(删除文件、文件夹)
1。实现方法:- (BOOL)removeItemAtPath:(NSString *)path error:(NSError **)errore.g.@property (nonatomic, strong) NSFileManager *fileManager;/* 根据给定的路径创建文件夹 */- (void) createFolder:(NSString *)p翻译 2014-01-26 15:17:47 · 1840 阅读 · 0 评论 -
enumerate Files and Folders(遍历)
1。对指定目录的浅遍历 - (NSArray *)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error e.g.- (void) actionEnumerate{ NSFileManager *fileManager = [[NSFileManager alloc] init];翻译 2014-01-26 11:23:51 · 1766 阅读 · 0 评论 -
save Objects to Files
1。将对象保存到磁盘文件中:该对象必须实现协议 - (void)encodeWithCoder:(NSCoder *)aCoder; - (instancetype)initWithCoder:(NSCoder *)aDecoder; NSKeyedArchiver:归档、存档,将对象读入(保存到磁盘文件中) NSKeyedUnarchiver:解档,将对象取出翻译 2014-01-26 16:40:52 · 934 阅读 · 0 评论 -
Detecting and Probing the Camera(检测,探测相机)
1。导入的库和使用的类 #import #import UIImagePickerControllerClass2。资源类型可用性: isSourceTypeAvailable BOOL isCameraOK = [UIImagePickerController isSourceTypeA翻译 2014-01-27 14:45:22 · 1048 阅读 · 0 评论 -
Gesture - Pan,Drag 拖移
@property (nonatomic, strong) UILabel *lbl;-(void)initLabel { CGRect labelFrame = CGRectMake(0.0f, 0.0f, 150.0f, 100.0f); self.lbl = [[UILabel alloc] initWithFrame:labelFram翻译 2014-01-20 17:40:30 · 1199 阅读 · 0 评论 -
Gesture - Tap单击
1。A tap gesture :discrete gesture (不连续手势)- (void)addGesture { UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTaps:)];翻译 2014-01-21 10:39:42 · 627 阅读 · 0 评论 -
Gesture-Pinch(捏)
1。Pinch works in two ways:scaling up / scaling down ,连续的手势@property (nonatomic, strong) UILabel *lbl;@property CGFloat currentScale; //比例- (void) handlePinches:(UIPinchGestureRecognizer*)pa翻译 2014-01-21 11:17:29 · 772 阅读 · 0 评论 -
IOS文件系统的简单描述
1。当ios app安装到设备后,文件结构显示如下Your.app : 是个文件夹,内容包括所有的资源,如app icons,sounds,etc.Documents/ : 所有用户创建的内容Library/ : 存储缓存文件,用户偏好等 Library/Caches/ :不会被系统备份,当app运行的磁盘空间不够或app运行暂停时,该文件夹中存储的缓存内容有可能被删除,翻译 2014-01-23 17:18:18 · 645 阅读 · 0 评论 -
GCD使用(三)执行延时操作
1。自带的延时(非GCD) - (void) printString:(NSString *)paramString{ NSLog(@"%@", paramString);}-(void)actionDelay { [self performSelector:@selector(printString:) withObject:@"Grand Centra翻译 2014-01-14 11:10:07 · 694 阅读 · 0 评论 -
GCD使用(二)执行与UI无关的操作
1。并发队列:dispatch_get_global_queue dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 参数:优先等级DISPATCH_QUEUE_PRIORITY_LOW , DISPATCH_QUEUE_P翻译 2014-01-14 10:29:38 · 589 阅读 · 0 评论 -
Record Audio(录音)
1。导入 #import 2。实现协议e.g.@property (nonatomic, strong)AVAudioRecorder *audioRecorder;@property (nonatomic, strong) AVAudioPlayer *audioPlayer;//录音后保存的音频文件的路径- (NSURL *) audi翻译 2014-01-21 17:51:01 · 3329 阅读 · 0 评论 -
NSTimer的简单使用
1。NSTimer:在将来的某一时刻开始一次性执行或是周期性执行指定的方法方法:+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds target:(id)target selector:(SEL)aSelector userInfo:(id)userInfo repeats:(翻译 2014-01-16 16:58:35 · 583 阅读 · 0 评论 -
Play video Files(播放视频)
1。实现: 导入: #import MPMoviePlayerController:可进行更加全面的视频显示设置 MPMoviePlayerViewController:可以放入navigationController,简单实现全屏显示, 或是用presentMoviePlayerViewController翻译 2014-01-22 17:05:27 · 4448 阅读 · 0 评论 -
Play Audio over Other Active Sounds
1。AVAudioSession:每一个ios应用都有一个audio session AVAudioSession *audioSession = [AVAudioSessionsharedInstance];2。设置类别: - (BOOL)setCategory:(NSString *)theCategory error:(NSError **)outError翻译 2014-01-22 11:45:42 · 825 阅读 · 0 评论 -
Gesture - Swipe滑动
1。-(void)addGesture { UISwipeGestureRecognizer swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)]; /* 可被侦测到的滑动方向 */ swi翻译 2014-01-20 10:21:06 · 1189 阅读 · 0 评论 -
Capture Thumbnails from Video Files (捕获视频中的屏幕截图)
1。使用MPMoviePlayerController在当前播放的视频中异步获取屏幕截图e.g.@property(nonatomic,strong)UIImage *captureImg; //保留抓捕的图像//播放视频- (void) startPlayingVideo:(id)paramSender{ NSBundle *mainBundle = [NSBund翻译 2014-01-23 11:37:58 · 1905 阅读 · 0 评论 -
GCD使用(四)操作只执行一次
1。dispatch_once ( &dispatch_once_t , block )e.g.static dispatch_once_t onceToken;void (^executedOnlyOnce)(void) = ^{ static NSUInteger numberOfEntries = 0; numberOfEntries++;翻译 2014-01-14 14:52:25 · 667 阅读 · 0 评论 -
GCD使用(六)串行队列的构造
1。串行队列: FIFO方式,并发时的异步操作不会在主线程进行 dispatch_queue_create(CStringID , 0): CStringID形式-com.COMPANY.PRODUCT.ID,不需要加@e.g. //串行队列,非mainQueue,非globalQueue dispatch_queue_t firstSerialQu翻译 2014-01-15 17:53:11 · 609 阅读 · 0 评论 -
IOS文件系统-获取相应文件夹
1。实现:NSFileManager - (NSArray *)URLsForDirectory:(NSSearchPathDirectory)directory inDomains:(NSSearchPathDomainMask)domainMask URLsForDirectory: NSLibraryDirectory(app应用的库文件夹) / NSCachesDirect翻译 2014-01-24 11:31:23 · 1039 阅读 · 0 评论 -
Taking Videos with the Camera(摄像)
1。导入库,实现协议 #import e.g.- (BOOL) cameraSupportsMedia:(NSString *)paramMediaType sourceType:(UIImagePickerControllerSourceType)paramSourceType{ __block BOOL result = NO;翻译 2014-01-28 14:00:45 · 1206 阅读 · 0 评论 -
Taking Photos with the Camera(拍照)
1。导入库,实现协议 #import e.g.- (BOOL) cameraSupportsMedia:(NSString *)paramMediaType sourceType:(UIImagePickerControllerSourceType)paramSourceType{ __block BOOL result = NO;翻译 2014-01-27 17:03:49 · 939 阅读 · 0 评论 -
Retrieving Assets from the Assets Library(不用内置GUI组件,检索手机中的相片/视频资源)
1.导入库,实现的协议 #import #import e.g.(一)- (void)actionRetrieve{ ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init]; [assetsLibrary enumerateGroupsWi翻译 2014-02-07 17:50:23 · 1635 阅读 · 0 评论 -
UIAlertView的使用
1。声明,使用:UIAlertView *alertView = [ [ UIAlertView alloc ] initWithTitle : @"title" message : @"message"翻译 2013-11-27 17:27:54 · 617 阅读 · 0 评论 -
Scheduling Local Notifications(调度本地通知)
即使app不在运行,或是在后台运行,也可以实现在某一特定时刻,发送通知给用户,这些通知还可以循环发送,如在每周的特定时间(类似推送) 一般可显示为Banner或是Alert形式,目前以Banner为主,即顶端横条,在ios5及以上的版本中,本地通知的显示形式已不能更改(可在设置-通用-通知中心中查看) 实现: 初始化:UILocalNotification *no翻译 2014-02-17 16:42:23 · 1859 阅读 · 0 评论 -
GCD使用(五)分组操作(group)
1。监听一组任务是否完成,完成后得到通知,执行其他的操作 dispatch_group_create :创建 dispatch_group_async / dispatch_group_async_f :分组操作 (组里的任务是一个接一个的操作) dispatch_group_notify (group , queue , block) :在组里的操作都结翻译 2014-01-15 16:56:49 · 1107 阅读 · 0 评论 -
Drawing Gradients(绘制渐变)
绘制过程: 创建上下文环境 -CGContextRef UIGraphicsGetCurrentContext (void); //CGContextRef currentContext = UIGraphicsGetCurrentContext(); 保存状态 -void CGContextSaveGState (CGContextRef c); // CGContex翻译 2014-03-27 16:18:48 · 1387 阅读 · 0 评论 -
Drawing Text(一)绘制文本
1.Enumerating and Loading Fonts(枚举出系统字体,并正确加载) Font families -> Font faces -(void) enumerateFonts { for (NSString *familyName in[UIFont familyNames]) { NSLog(@"Font Family = %翻译 2014-03-18 11:50:11 · 738 阅读 · 0 评论 -
Drawing Text(二)绘制文本,颜色的使用
//颜色构造 -- alpha:[0,1] 0-完全透明 1-不透明[UIColor redColor], .....+ (UIColor *)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha //设置绘制的起始位置及样式属性- (void)drawAtP翻译 2014-03-18 16:05:51 · 2413 阅读 · 0 评论 -
Drawing Images(绘制图像)
1.加载图像:+ (UIImage *)imageNamed:(NSString *)name //name:imageName 不用加扩展名如.png,...+ (UIImage *)imageWithData:(NSData *)data- (id)initWithContentsOfFile:(NSString *)path //[[UIImage alloc]initWit翻译 2014-03-19 13:51:22 · 1241 阅读 · 0 评论 -
Drawing Lines(绘制线条)
绘制过程: 设置颜色 - (void)set 设置线条宽度 - (void)CGContextSetLineWidth(CGContextRef c,CGFloat width); 设置连线类型 - (void)CGContextSetLineJoin (CGContextRef c,CGLineJoin join); //默认翻译 2014-03-19 15:55:42 · 1516 阅读 · 0 评论 -
Constructing Paths(构建路径)
points -> a shape:多个点构成一个形状shapes -> a path:多个形状构成一个路径绘制过程: 创建路径 -CGMutablePathRef CGPathCreateMutable (void); //CGMutablePathRef path = CGPathCreateMutable(); 设置起点 -void CGPathMoveT翻译 2014-03-19 17:28:05 · 884 阅读 · 0 评论 -
Drawing Rectangles(绘制矩形)
绘制过程: 创建路径 -CGMutablePathRef CGPathCreateMutable (void); //CGMutablePathRef path = CGPathCreateMutable(); 设置矩形 -CGRect CGRectMake (CGFloat x,CGFloat y,CGFloat width,CGFloat height); 将翻译 2014-03-20 10:10:36 · 1140 阅读 · 0 评论 -
Sending , Listening for and Reacting to Notifications (发送,监听通知)
方法://初始化通知内容 senderObject:self,userInfo:接收到通知时可从中获取到的信息+ (instancetype)notificationWithName:(NSString *)aName object:(id)senderObject userInfo:(NSDictionary *)userInfo//发送通知- (void)postNotifi翻译 2014-02-12 17:28:09 · 783 阅读 · 0 评论 -
Listening for and Reacting to Keyboard Notifications(键盘通知)
在输入文本时,键盘弹出,遮挡了视图内容,此时可通过键盘通知来使你的UI组件向上或向移动,或对它们进行重组。 各键盘通知: UIKeyboardWillShowNotification:包含user-info dictionary UIKeyboardDidShowNotification UIKeyboardWillHideNotification:包含u翻译 2014-02-13 13:45:32 · 874 阅读 · 0 评论 -
Storing Videos in the Photo Library(储存视频至手机)
1。framework:#import 方法:writeVideoAtPathToSavedPhotosAlbume.g. ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init]; NSURL *videoURL = [[NSBundle mainBundle] URLForR翻译 2014-01-29 11:52:43 · 787 阅读 · 0 评论 -
Editing Videos on an ios Device(编辑手机上的视频)
1。导入库: #import #import 实现协议: e.g./* 解决思路:pick a video from the photo library then display a video editor controller then allow the user to edit the翻译 2014-02-08 11:37:57 · 1135 阅读 · 0 评论