[ios 开发笔记]:一句话笔记
2014-04-23 17:54
316 查看
1、NSString转int
int a=[@"123" intValue];
同样适用于NSDictionary将NSNumber转为int
2、switch(statement) statement只支持int char 枚举
3,要看模拟器的document目录,要将其显隐
On Lion the users/[username]/library is hidden.
Use
chflags nohidden /users/[username]/library
in a terminal to display the folder.
4,iPhone的状态栏可以设置成半透明, 这是众所周知的, 用UINavigationController,在页面切换时, 如果你的子viewController的view是全屏的(480*320) 就会出现错位, 表现是所以的子view会向下偏移了 20像素
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
self.navigationController.navigationBar.translucent = YES;
[self.navigationController.view setNeedsLayout];
self.wantsFullScreenLayout = YES;
5.objectiveC无法检测到对象是否已释放,只能自己管理好。
如:
UIView *uivew=[[UIview alloc]init];
[uiview release];
这时,无法判断uiview是否被释放掉,因为uiview依然指向一个地址,他不为nil。
6.xib文件不更新/clear后重加载时只有一片灰色。
修改xib文件,运行,发现没有更新,product->clear依旧。然后将模拟器的app删除,运行,更惨,加载时只有灰色一片。
最后发现虽然在文件夹有看到这个xib,但项目本身并没有引用,在项目Build Phases->Copy Bundle Resources添加xib即可。
7.ASIHTTPRequest提前终止异步请求
[[ASIHTTPRequestsharedQueue]cancelAllOperations];
8.UIVIEW层次控制
置顶:[superview bringSubviewToFront:subview];
置底:[superview sendSubviewToBack:subview];
9.IOS5.1 对打开系统偏好设置的方式己被禁用。此前IOS5是可用的。
10.字符串是否含有某字符串
[str rangOfString:@"abc"].length > 0
11.subviews of uiscrollview
今天遍历uiscrollview subviews时发现在0,1位置多了两个水imageview,估计是水平和垂直滚动的指示器。
12.移除UIView上所有的subViews 除了遍历移除subView 还可以用这个方法: [[self.view subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
13.UIBarButtonItem 添加Action
UIButton可以用addTarget,UIBarButtonItem没有这个方法,而是直接用:setAction
14.判断是否retina屏幕
#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].s
ize) : NO)
15.withObject:传入整型参数
16.清除UIwebview产的的缓存
有时以页面形式加载,当页面更新时,再次访问也是缓存,怎么清空呢?
[[NSURLCachesharedURLCache] removeAllCachedResponses];
17.屏幕旋转无法触发
[window addSubview:viewController.view]无法触发。
改为
[window setRootViewController:viewController];//仅iOS4.0及以上支持。
int a=[@"123" intValue];
同样适用于NSDictionary将NSNumber转为int
2、switch(statement) statement只支持int char 枚举
3,要看模拟器的document目录,要将其显隐
On Lion the users/[username]/library is hidden.
Use
chflags nohidden /users/[username]/library
in a terminal to display the folder.
4,iPhone的状态栏可以设置成半透明, 这是众所周知的, 用UINavigationController,在页面切换时, 如果你的子viewController的view是全屏的(480*320) 就会出现错位, 表现是所以的子view会向下偏移了 20像素
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
self.navigationController.navigationBar.translucent = YES;
[self.navigationController.view setNeedsLayout];
self.wantsFullScreenLayout = YES;
5.objectiveC无法检测到对象是否已释放,只能自己管理好。
如:
UIView *uivew=[[UIview alloc]init];
[uiview release];
这时,无法判断uiview是否被释放掉,因为uiview依然指向一个地址,他不为nil。
6.xib文件不更新/clear后重加载时只有一片灰色。
修改xib文件,运行,发现没有更新,product->clear依旧。然后将模拟器的app删除,运行,更惨,加载时只有灰色一片。
最后发现虽然在文件夹有看到这个xib,但项目本身并没有引用,在项目Build Phases->Copy Bundle Resources添加xib即可。
7.ASIHTTPRequest提前终止异步请求
[[ASIHTTPRequestsharedQueue]cancelAllOperations];
8.UIVIEW层次控制
置顶:[superview bringSubviewToFront:subview];
置底:[superview sendSubviewToBack:subview];
9.IOS5.1 对打开系统偏好设置的方式己被禁用。此前IOS5是可用的。
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=TWITTER"]];
10.字符串是否含有某字符串
[str rangOfString:@"abc"].length > 0
11.subviews of uiscrollview
今天遍历uiscrollview subviews时发现在0,1位置多了两个水imageview,估计是水平和垂直滚动的指示器。
12.移除UIView上所有的subViews 除了遍历移除subView 还可以用这个方法: [[self.view subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
13.UIBarButtonItem 添加Action
UIButton可以用addTarget,UIBarButtonItem没有这个方法,而是直接用:setAction
14.判断是否retina屏幕
#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].s
ize) : NO)
15.withObject:传入整型参数
[self performSelector:@selector(frontButtonScaleUp) withObject:[NSNumber numberWithInt:[sender tag]] afterDelay:delay - elapsed];
[self performSelector:@selector(frontButtonScaleUp) withObject:(id)[sender tag] afterDelay:delay - elapsed];
16.清除UIwebview产的的缓存
有时以页面形式加载,当页面更新时,再次访问也是缓存,怎么清空呢?
[[NSURLCachesharedURLCache] removeAllCachedResponses];
17.屏幕旋转无法触发
[window addSubview:viewController.view]无法触发。
改为
[window setRootViewController:viewController];//仅iOS4.0及以上支持。
相关文章推荐
- html页面在IOS-safari浏览器下绑定点击绑定事件的div时会显示灰色框的问题
- IOS拷贝文件到沙盒
- ios中tabbar得title和navigationbar的title如何修改
- iOS 设置字体 自定义字体
- [IOS] 图片显示 imageNamed, initWithContentsOfFile 的区别
- AVPlayer基本使用方法
- [转]iOS ARC机制 weak strong
- R/BioC序列处理之三:Biostrings模式匹配和序列比对
- R/BioC序列处理之二:Biostrings序列的基本操作
- R/BioC序列处理之一:Biostrings常量与序列容器
- Mac终端命令 统计iOS工程中代码行数
- 论坛源码推荐(4月23日):支付形式的iOS实用库 能够调整歌曲播放速度的应用 快速的集成和开发框架
- IOS-试图旋转效果的实现
- IOS Canvas 动画
- iOS项目结构目录
- iOS CoreAnimation
- iOS 开发之Target-action模式
- iOS杂谈-图片拉伸的实现
- IOS之同步请求、异步请求、GET请求、POST请求
- ios 支付宝支付问题解决demo的报错