1:setFrame引发点击不能响应问题。
具体是这样的,在一个控件上放置多个控件时,如果父控件setFrame没有将子控件包含进来,那么点击子控件就不会有反应。所以操作此函数一定要小心。
2: 消息传递。
消息会从子窗口传递给父窗口。如果子窗口将响应的信息截住了,就不会再往父窗口传递。
3:文件读取
如果要读取资源的话,如果读取的文件是非图片格式资源的时候,添加文件时,使用添加引用的方式,在Standard Editor的Project中看到的显示一个蓝色的文件夹,
如 “Database/login.db”数据库文件。使用 [[NSBundle mainBundle] bundlePath] 得到工程.app文件里面就会包含./Database/login.db文件,如果不是已引用方式
添加,该路径是不存在此文件的,这个一定要注意。
一般在IOS中操作文件的就这两个函数,NSSearchPathForDirectoriesInDomain,[[NSBundle mainBundle] bundlePath] ,他们得到的文件路径都是模拟器路径下面,但是有一点点不同,请参见代码:
/*
NSArray *documentsPaths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory
, NSUserDomainMask
, YES);
NSLog(@"%@", documentsPaths);// "/Users/weizhiqiangzz/Library/Application Support/iPhone Simulator/6.0/Applications/D656D8E6-9F81-4D73-A33E-C641220EDF7B/Documents"
NSString *databaseFilePath=[[documentsPaths objectAtIndex:0] stringByAppendingPathComponent:@"/Database/login.db"];
NSLog(@"%@", databaseFilePath);
//*/
//*
NSString *documentsPaths=[[NSBundle mainBundle]bundlePath];
NSLog(@"%@", documentsPaths);///Users/weizhiqiangzz/Library/Application Support/iPhone Simulator/6.0/Applications/D656D8E6-9F81-4D73-A33E-C641220EDF7B/SSShow.app
NSString *databaseFilePath=[documentsPaths stringByAppendingPathComponent:@"./Database/login.db"];
4:调试的时候,很多信息不能直观地查看,
可以在调试窗口,对指定的变量,点击右键:Print Description of "***".
5: JSON数据解析可以使用:NSJSONSerialization, 常用的容器:NSDictionary, NSMutableDictionary, NSArray, NSMutableArray.
NSArray-->NSDictionary-->NSMutableArray-->NSDictionary,也就是说可以相互转化。
如:
-(void) parseCategory:(NSArray*) _arrCategory withTarget:(id)target
{
arrCategory = [[NSMutableArray alloc]init];
for(i=0; i<_arrCategory.count; ++i)
{
SSCategory* catItem = [[SSCategory alloc]init];
NSDictionary *dicItem = [_arrCategory objectAtIndex:i];
if([dicItem valueForKey:@"children"] != nil)
{
NSMutableArray* arrChi=[dicItem valueForKey:@"children"];
for(j=0; j<arrChi.count; ++j)
{
SSChildCategory *chiCatItem = [[SSChildCategory alloc]init];
NSDictionary *chiItem = [arrChi objectAtIndex:j];
6:NSString 有 intValue, floatValue等类似函数,可以将一个NSString转变成 int, float等数据类型。
7:如何将UIView上面的数据保存成一个图片
UIGraphicsBeginImageContextWithOptions(self.bounds.size, YES, self.layer.contentsScale);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
8: svn遇到不能看见/不能提交.a文件
用VERSIONS做SVN管理,结果发现.a文件在VERSIONS时根本不显示,翻了一遍菜单才发现VEIW->SHOW IGNORED ITEMS选中,才会显示,然后才能添加到SVN里