俺是一个瓜娃!!!
xiaozhao-521 · 共 254 篇文章
Moving Without Animation
1. Initialize the two rectangles required for the starting and ending positions for the image in line 4. 2. Add the image to the NSImageView that will be moved back and forth between these locations in line 5. 3. Add this NSImageView to the BaseView so that we can see the action in line 6. - (id)in…
2010-12-10 10:52 · core animation · 评论(0)
[iPhone][cocoa] 如何计算两个日期之间的天数
问题 : 如何计算两个日期之间的天数 使用到的类 : NSDate NSDateComponents NSCalendar 1: NSDate objects represent a single point in time. 2: NSDateComponents NSDateComponents encapsulates the components of a date in an extendable, object-oriented manner. 3: NSCalendar Calendars encapsulate information about systems of rec…
2010-12-09 15:23 · objective-c · 评论(0) · Cocoa
navigation bar 自定义背景图片
在你要写navigation bar的m文件前面放一段这个: @interface UINavigationBar (MyCustomNavBar) @end @implementation UINavigationBar (MyCustomNavBar) - (void) drawRect:(CGRect)rect { UIImage *barImage = [UIImage imageNamed:@"xxxxx.png"]; [barImage drawInRect:rect]; } @end 导航栏添加自定义标题(navigationItem添加标题视图) 在开发中经常会用到导航器,在…
2010-12-09 10:18 · objective-c · 评论(0)
iphone 日期计算
-(NSDate *)getPriousDateFromDate:(NSDate *)date withMonth:(int)month { NSDateComponents *comps = [[NSDateComponents alloc] init]; [comps setMonth:month]; NSCalendar *calender = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDate *mDate = [calender dateByAddingComponents:comp…
2010-12-08 17:06 · objective-c · 评论(0)
UITabBar 和獨立的 UItableView 問題?这个问题俺也遇到了
用TabView時,每一個Tab各自獨立指定xib,碰到 TableView不知道為甚麼就是有問題 現在 mainwindow 在 IB 大概是這樣: Tab Bar Controller |-Navigation Controller |-Navigation Controller ... |-Navigation Controller |-Navigation Bar |-View Controller(NIB name 設定成 MyTableView) |-Navigation Item |-Tab Bar Item MyTableView是: |-File's Owner (指定 M…
2010-12-08 11:20 · objective-c · 评论(0)
多线程之NSInvocationOperation
多线程之NSInvocationOperation T 多线程编程是防止主线程堵塞,增加运行效率等等的最佳方法。而原始的多线程方法存在很多的毛病,包括线程锁死等。在Cocoa中,Apple提供了 NSOperation这个类,提供了一个优秀的多线程编程方法。 本次介绍NSOperation的子集,简易方法的NSInvocationOperation: @implementation MyCustomClass - (void)launchTaskWithData:(id)data { //创建一个NSInvocationOperation对象,并初始化到方法 //在这里,selector参数…
2010-11-15 15:10 · objective-c · 评论(0) · Cocoa · 编程 · Apple · 多线程
使用NSOperation建立多任务网络连接
博主: 易飞扬 原文链接 : http://www.yifeiyang.net/iphone-web-development-skills-of-the-articles-3-use-a-multi-task-network-connection-nsoperation/ 转载请保留上面文字。 iPhone开发技巧之网络篇(3)--- 使用NSOperation建立多任务网络连接 在网络应用程序中,经常需要多任务连接来提高程序的性能。比如多任务下载,多任务HTTP请求等,即线程控制模型中的 工作群模型 。使用 NSOperation 可以很容易实现这个功能。下面就以使用NSOperation…
2010-11-15 15:04 · objective-c · 评论(0) · 网络应用 · Google · Yahoo · Web · 多线程
cocos2d 总结:四 背景的循环移动
1:CCSpriteFrameCache 1): 从*.plist文件中读取内容设置 CCSpriteFrameCache ,该对象是一个全局对象 // Load all of the game's artwork up front. CCSpriteFrameCache* frameCache = [CCSpriteFrameCache sharedSpriteFrameCache]; [frameCache addSpriteFramesWithFile:@"game-art.plist"]; 2): Now uses the image from the Texture Atlas. …
2010-11-08 14:34 · objective-c · 评论(1) · velocity · UP
cocos2d 总结:三 CCSprite
CCSprite 1: CCSpriteBatchNode ???????(可能是多个CCSprite) CCSpriteBatchNode* batch = [CCSpriteBatchNode batchNodeWithFile:@"bullet.png"]; CCArray* bullets = [batch children]; 2:用多个单独的文件创建动画 CCAnimation, CCSpriteFrame +(CCAnimation*) animationWithFile:(NSString*)name frameCount:(int)frameCount delay:(flo…
2010-11-08 14:18 · 评论(0)
cocos2d 总结:二scenes and layers
scenes and layers 1:显示的第一个场景 runWithScene [[CCDirector sharedDirector] runWithScene:[FirstScene scene]]; 2:场景转换 replaceScene (1)有转换效果 CCSlideInBTransition* transition = [CCSlideInBTransition transitionWithDuration:3 scene:[OtherScene scene]]; [[CCDirector sharedDirector] replaceScene:transition]; 或…
2010-11-08 13:50 · objective-c · 评论(0)
cocos2d 总结:一
1:在创建CCLayer的子类时,默认的情况下,不能响应触摸事件 在-(id)init { }打开事件处理: // enable touch input self.isTouchEnabled = YES; // enable accelerometer input self.isAccelerometerEnabled = YES; -(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { } -(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent …
2010-11-08 13:32 · objective-c · 评论(0) · Go · F#
在iPhone播放背景音乐和按键生效的代码
作者 lhp7424521 , 原帖 http://www.cocoachina.com/bbs/read.php?tid-19166.html 1、背景音乐播放 支持mp3格式 循环播放长音乐 这种播放音乐的方式导入框架#import <AVFoundation/AVFoundation.h>; NSString *musicFilePath = [[NSBundle mainBundle] pathForResource:@"changan" ofType:@"mp3"]; //创建音乐文件路径 NSURL *musicURL = [[NSURL alloc] initFileURLWi…
2010-10-28 15:24 · objective-c · 评论(0) · HTML · 音乐 · BBS · PHP · 框架
iPhone 应用开发:音频播放
iPhone 应用开发:音频播放 在 iPhone 应用或者是游戏的开发过程中,对声音的支持是必不可少的。没有音效的软件是残缺的,用户体验也会大打折扣,下面是自己对iPhone音频的一点总结。 iPhone OS 音频分类: (1)High level, easy to use •System Sound API - short sounds •AVAudioPlayer class - ObjC, simple API (2)Lower level, takes more effort but much more control •Audio Toolbox - recording and…
2010-09-13 12:03 · objective-c · 评论(0) · 应用服务器 · 音乐 · 游戏 · OS · Apple
iPhone 对Plist文件进行读写
读Plist文件 NSString *errorDesc = nil; NSPropertyListFormat format; NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *plistPath = [rootPath stringByAppendingPathComponent:@"bookmarks.plist"]; if (![[NSFileManager defaultMa…
2010-09-13 11:57 · 评论(0)
IPhone数据库操作代码例子
//database operation 打开数据库 -(BOOL) opendatabase{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"mydb.sql"]; NSFileManager …
2010-09-01 17:39 · objective-c · 评论(0) · SQL · SQLite