不会开机的男孩

Tips

| Comments

  1. ARC 编译时遇到的相关问题
  2. install cocoapods 问题
  3. Adding Unit Tests to an existing iOS project with Xcode 4
  4. NSDateFormatter 问题
  5. 写博客命令
  6. php apigen command demo
  7. ios6 下因为横屏问题导致UIImagePickerController崩溃
  8. ios5 下UILabel sizeToFit导致 UILabel不换行
  9. cocoapods pod install 慢

ARC 编译时遇到的相关问题

  1. 自己的项目没有使用ARC, 其他代码使用ARC
  2. 自己项目使用ARC, 其他代码没有使用ARC

在Xcode Build Phases 里面的 Compile Source 需要特殊处理的文件 增加 COmpiler Flags 1. 第一种情况 添加 -fobjc-arc 2. 第二种情况 添加 -fno-objc-arc

install cocoapods 问题

In Preview of OS X Mountain Lion, Xcode has been distributed as X.app. And Commandline Tools are not installed by default. Commandline Tools contains cc/gcc that you must need to build environment.

Open Xcode and cmd +, to open Preferences panel where you can install Commandline Tools:

alt text

then

gem install hpricot
gem install cocoapods

Adding Unit Tests to an existing iOS project with Xcode 4

When you build a new iPhone or iPad app from scratch, you can generate a new project with tests using Xcode’s project templates, and the test dependency is set up correctly.

However, if you add a unit test target to an existing iOS project, there are some manual steps required to set up the target correctly. Following these steps will get you up and running quickly:

Project MyExistingApp -> + Add Target -> iOS -> Other -> Cocoa Unit Testing Bundle Name the new target something like “Unit Tests” or “MyAppTests” Select your new “Unit Tests” target and click the Build Phases tab, expand Target Dependencies and add MyExistingApp as as a Target Dependency Click the Build Settings tab and set the Bundle Loader setting to

$(BUILT_PRODUCTS_DIR)/MyExistingApp.app/MyExistingApp

Set the Test Host build setting to

$(BUNDLE_LOADER)

Go back to your app target (not the test target), set the Symbols Hidden by Default build setting to NO

That should take care of it, and you can now start adding tests for your app. With this configuration, you continue to add application classes only to your app target, and add test classes only to your test target. Since the tests run in the app running in the simulator, the code under test can safely instantiate views and fonts, which would otherwise cause OCunit to crash when running without the Test Host setting.

NSDateFormatter 问题

最近在使用新版本xcode4.6 或是 因为新版本的sdk6.1 日期转换出现了一个问题. 而且是在模拟器可以, 真机不行的问题. 问题是 时间格式中的 “Thu Jan” 无法被识别出来. 这个挺奇怪的, 可能新版本修改了默认行为. 下面是解决方法

//time format: @"Thu Jan 17 13:59:11 +0000 2013"
s_format = [[NSDateFormatter alloc] init];
[s_format setDateFormat:@"eee MMM dd HH:mm:ss ZZZZ yyyy"];
[s_format setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]]; //之前少了设定Locale

写博客命令

rake new_post['filename'];
rake generate 
rake preview

apigen command demo

/usr/bin/php /Users/ygcurer/apigen/apigen.php --source /Applications/XAMPP/xamppfiles/htdocs/curer/application/controllers/api --destination /Applications/XAMPP/xamppfiles/htdocs/curer/doc_test --title curer --charset UTF-8 --access-levels public,protected --internal no --php yes --tree yes --deprecated no --todo no --download no --source-code yes --colors yes --progressbar no --update-check no

ios6 下因为横屏问题导致UIImagePickerController崩溃

apple 自己的UIImagePickerController 不支持横屏,所以,在ios6系统下,打开相册或是摄像头就回崩溃。。。。 这是apple自己的bug,在6.0时被发现,6.1 修复,但是,目前看来,在6.1.1 又回来了。。。。这是一个work around的方法,或是一个唯一的简单方法。

@implementation UIImagePickerController (UIImagePickerCategory)

- (BOOL)shouldAutorotate
{
    return NO;
}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

@end

ios5 下UILabel sizeToFit导致 UILabel不换行

很奇怪的Bug 在ios5.0下,sizeToFit 之后,UILabel 不换行,但是在ios6, ios7 下面没有任何问题, 这里应该是apple的bug被修复了。在ios5下,慎用 sizeToFit

在使用sizeToFit的原因是因为需要置顶UILabel,这里有一个比较简单的方式 stringByAppendingString:@”\n \n \n \n \n \n \n \n”]

通过设置在Label中的字符串,增加额外的空行,来达到置顶的要求

cocoapods pod install 慢

pod install --verbose --no-repo-update

Comments