iPhone随手记
来源:互联网 发布:淘宝双11红包雨 编辑:程序博客网 时间:2024/06/05 17:11
1、图片拉伸
UIImage *img = [UIImage imageNamed:@"inputbox.png"];UIImage *stretchedImage = [img stretchableImageWithLeftCapWidth:20.0f topCapHeight:10.0f];
2、键盘高度
ios5 以前中文键盘高度216.0f
ios5 以后中文键盘高度252.0f
3、emoji小图标
http://www.easyapns.com/iphone-emoji-alerts
4、使用ASI时,需要引入的一些framework
5、获取documents目录和资源
// NSString *cookiesPath = [[self applicationDocumentsDirectory] stringByAppendingString:@"/session.Cookies"];- (NSString *)applicationDocumentsDirectory { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; return basePath;}
获取资源:NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"js"];
6、格式化时间
NSDate *date = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"MM-dd-yyyy HH:mm:ss"]; NSLog(@"%@ \n",[dateFormatter stringFromDate:date]);
7、区分设备是否是iPad
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { // iPad style UI} else { // iPhone and iPod touch style UI}
8、touches -> touchesPoint
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint touchPoint = [touch locationInView:self]; [self handleTouchEvent:touchPoint touchType:Touch_Down_Event_Type];}
9、获取 info.plist 文件中的值
NSBundle *mainBundle = [NSBundle mainBundle]; NSDictionary *infoDictionary = [mainBundle infoDictionary]; [header setObject:[infoDictionary objectForKey:@"CFBundleVersion"] forKey:@"version"];
10、NSNotificationCenter
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter addObserver:self selector:@selector(tableHeaderButtonClicked:) name:kTableHeaderButtonClicked object:nil];[[NSNotificationCenter defaultCenter] postNotificationName:kTableHeaderButtonClicked object:nil userInfo:nil];[[NSNotificationCenter defaultCenter] removeObserver:self name:kTableHeaderButtonClicked object:nil];
11、模拟器中程序文件位置
打开某个文件夹,快捷键 command + shift + g, 把下面的地址粘进去, Enter
~/Library/Application Support/iPhone Simulator
12、url encode
url = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)url, nil, nil, kCFStringEncodingUTF8);
13、在xcode4中使用NSZombieEnabled调试程序
http://stackoverflow.com/questions/2190227/how-do-i-setup-nszombieenabled-in-xcode-4
14、NSString编码转换(偶遇乱码问题)
NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);NSString *encodingStr = [[NSString alloc] initWithData:request.responseData encoding:enc];
15、判断是否是simulator
#if TARGET_IPHONE_SIMULATOR // Simulator code#else // Device code#endif
- iPhone随手记
- 随手记在iPhone X上的真机适配实践总结
- 随手记
- 随手记
- 随手记
- 随手记
- 随手记
- 随手记
- 随手记
- 随手记
- 随手记
- 随手记
- 随手记
- 随手记
- 随手记
- 随手记
- 随手记
- 随手记
- php常用转义函数
- Log4net 框架系列:log4net日志文件在asp.net中的应用实例-记录系统错误
- WM算法详解
- CGRect笔记 mark
- MyEclipse删除一行快捷键
- iPhone随手记
- BM算法详解
- 删除文件中的 ^M 字符
- 模式匹配之路
- Ant与Junit结合
- Win8下连接共享的HP打印机
- 同時兩個surfaceview camera 中的一些開發問題
- dos命令行输入adb shell命令为什么报错 没有这个外部命令
- Ilist<>与List<> 的区别