- 博客(114)
- 收藏
- 关注
翻译 Detecting and Probing the Camera(检测,探测相机)
1。导入的库和使用的类 #import #import UIImagePickerControllerClass2。资源类型可用性: isSourceTypeAvailable BOOL isCameraOK = [UIImagePickerController isSourceTypeA
2014-01-27 14:45:22 1056
翻译 save Objects to Files
1。将对象保存到磁盘文件中:该对象必须实现协议 - (void)encodeWithCoder:(NSCoder *)aCoder; - (instancetype)initWithCoder:(NSCoder *)aDecoder; NSKeyedArchiver:归档、存档,将对象读入(保存到磁盘文件中) NSKeyedUnarchiver:解档,将对象取出
2014-01-26 16:40:52 944
翻译 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 1862
翻译 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 1778
翻译 Creat folders -创建文件夹
1。实现 - (BOOL)createDirectoryAtPath:(NSString *)pathwithIntermediateDirectories:(BOOL)createIntermediates attributes:(NSDictionary *)attributes error:(NSError **)errorcreateIntermediates:YES-若
2014-01-24 17:04:03 995
翻译 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 1003
翻译 IOS文件系统-获取相应文件夹
1。实现:NSFileManager - (NSArray *)URLsForDirectory:(NSSearchPathDirectory)directory inDomains:(NSSearchPathDomainMask)domainMask URLsForDirectory: NSLibraryDirectory(app应用的库文件夹) / NSCachesDirect
2014-01-24 11:31:23 1048
翻译 IOS文件系统的简单描述
1。当ios app安装到设备后,文件结构显示如下Your.app : 是个文件夹,内容包括所有的资源,如app icons,sounds,etc.Documents/ : 所有用户创建的内容Library/ : 存储缓存文件,用户偏好等 Library/Caches/ :不会被系统备份,当app运行的磁盘空间不够或app运行暂停时,该文件夹中存储的缓存内容有可能被删除,
2014-01-23 17:18:18 656
翻译 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 1913
翻译 Play video Files(播放视频)
1。实现: 导入: #import MPMoviePlayerController:可进行更加全面的视频显示设置 MPMoviePlayerViewController:可以放入navigationController,简单实现全屏显示, 或是用presentMoviePlayerViewController
2014-01-22 17:05:27 4482
翻译 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 833
翻译 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 3362
翻译 Play audio Files (播放音频文件)
1。必须导入 AV Foundation framework : #import 2。实现协议: e.g.@property (nonatomic, strong)AVAudioPlayer *audioPlayer;- (void)actionPlay { //为后续异步加载,使用并行全局队列 dispatch_queu
2014-01-21 15:49:52 1270
翻译 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 784
翻译 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 635
翻译 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 754
翻译 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 1210
翻译 Gesture - Rotation旋转
1。@property (nonatomic, strong) UILabel *lbl;@property CGFloat rotationAngleInRadians; //旋转的角度- (void) handleRotations:(UIRotationGestureRecognizer *)paramSender{ if (self.lbl == nil)
2014-01-20 16:34:41 637
翻译 Gesture - Swipe滑动
1。-(void)addGesture { UISwipeGestureRecognizer swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)]; /* 可被侦测到的滑动方向 */ swi
2014-01-20 10:21:06 1199
翻译 NSTimer的简单使用
1。NSTimer:在将来的某一时刻开始一次性执行或是周期性执行指定的方法方法:+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds target:(id)target selector:(SEL)aSelector userInfo:(id)userInfo repeats:(
2014-01-16 16:58:35 591
翻译 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 618
翻译 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 1115
翻译 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 677
翻译 GCD使用(三)执行延时操作
1。自带的延时(非GCD) - (void) printString:(NSString *)paramString{ NSLog(@"%@", paramString);}-(void)actionDelay { [self performSelector:@selector(printString:) withObject:@"Grand Centra
2014-01-14 11:10:07 703
翻译 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 599
翻译 GCD使用(一)执行与UI有关的操作
1。使用GCD时,与UI有关的操作只能放在主线程中进行 dispatch_get_main_queue, dispatch_async ( dispatch_queue_t queue, dispatch_block_t block) 异步执行,参数:操作队列,执行块 dispatch_async_f ( dispatch_
2014-01-09 11:00:22 561
翻译 Block的使用(二)变量
1。 变量访问:外部变量,在block内是只读 在外部声明变量时加上前缀__block,在block内成可读写2。属性访问:在方法内部的内联(匿名)block中出现的self表示该 方法所属的类本身,可通过.property对该类的属性进行读取,设置 对于独立的block(即单独声明定
2014-01-09 09:55:52 545
翻译 Block的使用(一)基本语法
1。 Block用法: 一般是用来表示、简化一小段的程式码,它特别适合用来建立一些同步执行的程式片段、封装一些小型的工作或是用来做为某一个工作完成时的回传呼叫(callback) 。2。作为独立的代码块使用 returnType ( ^blockName ) (paramType1, paramType2) = ^ (paramType1 pa
2013-12-18 11:10:26 564
翻译 GCD-queue介绍
三种queue类型 Main queue : 主队列执行主线程,调用所有与UI相关的方法,使用dispatch_get_main_queue函数检索句柄主队列 Concurrent queues : 并发队列,执行异步或同步任务。使用dispatch_get_global_queue函数检索句柄并发队列。 Serial queues : 连续串行队列,不在
2013-12-17 15:43:37 781
翻译 Storyboard-segue的使用
1。嵌入Navigation Controller :Editor -> Embed in -> Navigation Controller2。在IB上创建segue,并设置id3。传递数据 - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender //是否执行segu
2013-12-17 11:28:49 1433
翻译 UICollectionViewCell上显示编辑菜单
1。显示编辑菜单(如复制,粘贴等) - (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath //是否显示菜单 - (BOOL)collectionView:(UICollectionView *)collectio
2013-12-16 17:07:24 5055
翻译 UICollectionView-添加自定义交互(如手势等)
1。相关方法 - (void)invalidateLayout // 刷新布局e.g. - (void) handlePinches:(UIPinchGestureRecognizer *)paramSender{ CGSize DefaultLayoutItemSize = CGSizeMake(80.0f, 120.0f); //这是原先设置的默认的尺寸大
2013-12-16 16:24:02 3562 1
翻译 UICollectionView的HeaderView、FooterView
1。相关方法 - (void)registerNib:(UINib *)nib forSupplementaryViewOfKind:(NSString *)kind withReuseIdentifier:(NSString *)identifier //注册xib,以便后续重用 - (UICollectionReusableView *)collectionVie
2013-12-16 15:13:17 9615
翻译 UICollectionView-事件
1。UICollectionViewCell状态 highlighted:手指按下没抬起来 selected:手指按下,之后抬起来 selectedBackgroundView:选中背景2。 事件 - (void)collectionView:(UICollectionView *)collectionView di
2013-12-16 10:51:10 3098
翻译 UICollectionView-数据源
1。 数据源 - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView //有多少个section,默认为1 - (NSInteger)collectionView:(UICollectionView *)collectionView nu
2013-12-13 16:40:18 1759
翻译 UICollectionView-布局
1。类似UITableView,不同之处:可多列(以二维方式存在)2。 布局方式 minimumLineSpacing:最小行间距,CGFloat minimumInteritemSpacing:最小项间距(单元格之间的空隙),CGFloat itemSize:每个单元格尺寸大小,CGSize scrollDi
2013-12-13 16:37:07 1084
翻译 UITableViewController中的刷新控件(UIRefreshControl)
1。位于table view的顶端,下拉可刷新。只能是在UITableViewController里可用2。初始化 self.refreshControl = [[UIRefreshControl alloc] init]; [self.refreshControl addTarget:self action:@selector(ha
2013-12-11 17:55:59 1705
翻译 在表中移动,删除 row,section
1。位置索引:base_index = 0 2。UITableView.h 针对表进行删除或移动 rows / sections操作 - (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath //移动row - (void
2013-12-11 15:52:09 1158
翻译 在表的单元格上显示编辑菜单
1。编辑菜单:包含剪切,复制,粘贴。。。等2。 //长按某行时,是否显示编辑菜单 - (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath //当可显示编辑菜单时,哪些操作选项可显示 - (BOO
2013-12-11 11:25:02 634
翻译 创建表的页眉,页脚(Header and Footer)
1。一个表可以有多个section,每个section都可以各有一个header and footer2。 可自定义视图内容(包括文本,图像等)作为页眉,页脚 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section //页眉视图 tabl
2013-12-10 17:27:10 1426
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人