簡單學日語 2.0 上架了
https://itunes.apple.com/tw/app/jian-dan-xue-ri-yu/id907920405?mt=8
iOS 的 app 真麻煩
iOS 的版本只要一升級
就得回頭 revise 所有的 app
要不然就會莫名其妙的閃退
日前心血來潮看了一下這個 app
才發現早就閃退到不行
只好趕快改一改再上架更新
簡單學日語 2.0 上架了
https://itunes.apple.com/tw/app/jian-dan-xue-ri-yu/id907920405?mt=8
iOS 的 app 真麻煩
iOS 的版本只要一升級
就得回頭 revise 所有的 app
要不然就會莫名其妙的閃退
日前心血來潮看了一下這個 app
才發現早就閃退到不行
只好趕快改一改再上架更新
Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil
Symptom: Normal but crash in iOS 7 device.
Possible reason : Use some “Baseline” constraints (Only supported after iOS 8) in storyboard.
Solution : Remove any “Baseline” constraints of that page crashed in storyboard.
That is the keyword I Googled for solution and no luck.
I’m too old to learn new source control mechanism like Git so I stuck on SVN with XCode.
It works perfect usually but sometimes it show “xxx is not under version control”.
For me, the reason is some special character in file name , in my case , the @ character.
I googled and tried to fixed this issue but no luck.
And today, finally, I solved this issue with one single step, simple and straight.
Open “Terminal” application, go to the project folder and keyin this
svn commit -m “Happy SVN”
And you’ll see all the files (including file name with @ character) are committed successfully.
I don’t know why the commit won’t succeed in XCode, but I’m happy that it works in command line mode.
Update on 2016/03/02:
Sometimes you have to make those @xx.png files the Add status (with A in the right) in Xcode first before you do the command-line svn commit.
Let’s define something in this scenario :
1.Receiver app – to be invoked via custom URL
2.Sender app – who wants to invoke the app
3.Custom URL scheme – define as “happygo”
For Receiver app, here’s what to do:
1.Define the url scheme in Project/Targets/Info/URL Types as follow
2.AppDelegate.m – Two methods to be implemented.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { return YES; //must return YES }
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { //Check if the scheme was valid if ([[url scheme] isEqualToString:@"happygo"]) { NSString *query = [url query]; NSArray *queryComponents = [query componentsSeparatedByString:@"&"]; for (int i=0; i<[queryComponents count]; i++) { NSArray *oneParam = [[queryComponents objectAtIndex:i] componentsSeparatedByString:@"="]; NSString *sValue = @""; NSString *sKey = [oneParam objectAtIndex:0]; if (oneParam.count==2) { sValue = [oneParam objectAtIndex:1]; } } //Here is what you want to do, write here. return TRUE; //return TRUE because of valid scheme } return FALSE; //invalid scheme, skip process }
For Sender app, here’s what to do :
1.Add the following to info.plist
<key>LSApplicationQueriesSchemes</key> <array> <string>happygo</string> </array>
2.Invoke the receiver app via URL form, sample source code as follow
NSString *sURL = [NSString stringWithFormat:@"happygo://www.domain.com?name=Good&phone=123123"]; NSURL *myURL = [NSURL URLWithString:sURL]; if ([[UIApplication sharedApplication] canOpenURL:myURL]) { [[UIApplication sharedApplication] openURL:myURL]; } else { NSLog(@"--bad url--"); }
Actually, you can even invoke the app via Safari Browser.
Just input the URL in Safari, press GO, and the receiver app will be invoked.
I had this problem twice, I googled the same article to do the same actions to fix.
Here I wrote down to remember myself.
Error : “paired device unavailable for development” showed in XCode when new to Apple Watch
Fix steps :
Good luck.
1.Clear the title attribute to empty.
2.Set the Image Insect attribute of the Tabbar item as follow
And you’re good to go.
Happy Tabbaring…
I found that it’s really weird to set UITabbar tintColor.
It won’t work if you change the Tint attribute in the View section.
You have to add the attribute by yourself to make it work. Check this out.
Happy Tabbaring !!
I’ve been bothered by this issue for a long time.
And finally I’d decide to find the best practice today to do this job.
Here are the steps:
Step 1.
Create SVN repository, for example, http://svn.domain.com/myrepo
Step 2.
Create XCode project, Assume the project path is Documents/iosprojects/milkshaker
Step 3.
Open OS X app Terminal which is command line mode.
Step 4.
In terminal, cd to the parent directory of your project directory (Documents/iosprojects in this example)
cd /Users/yourname/Documents/iosprojects
Step 5.
The most import step, svn import (NOT ADD) as following command
svn import -m “New Import “ milkshaker/ http://svn.domain.com/myrepo
The syntax is
svn import -m “<remark message>“ <project directory>/ <SVN URL>
Key in the userid and password and you’re good to go.
Step 6.
After step 5 was done.
Open XCode app, try Source control->Check out
Key in the SVN URL, userid and password to checkout the project to local directory.
That would be all I want to share, happy SVNing !!
UITableViewCell 有 heightForRowAtIndexPath 可以指定
但是實務上總是會碰到客戶的要求:「動態列高」
若是「想以文字內容決定 UILabel 的高度」
可以使用下面的程式
先用「文字,字型和寬度」(這點要事先決定,不然沒辦法算)計算出 UILabel 的高度
然後再用這個算出來的高度去 initWithFrame
搞定,收工放飯
+(float) getHeightForText:(NSString*) text withFont:(UIFont*) font andWidth:(float)width {
CGSize constraint = CGSizeMake(width , 20000.0f);
CGSize title_size;
float totalHeight;
SEL selector = @selector(boundingRectWithSize:options:attributes:context:);
if ([text respondsToSelector:selector]) {
title_size = [text boundingRectWithSize:constraint
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{ NSFontAttributeName : font }
context:nil].size;
totalHeight = ceil(title_size.height);
} else {
title_size = [text sizeWithFont:font
constrainedToSize:constraint
lineBreakMode:NSLineBreakByWordWrapping];
totalHeight = title_size.height ;
}
CGFloat height = MAX(totalHeight, 40.0f);
return height;
}
如果你會看到這篇文章
很有可能你是因為想判斷 iPhone 的不同型號
然後做不同的顯示(字體大小、間距….)
現在讓我告訴你
不要再這麼做了
因為東西南北有的沒有的原因
我落入了「判斷手機型號,然後寫不同的顯示 code」的地獄深淵
好不容易寫完了
交付使用者測試時卻發現「走鐘」現象
奇怪的是在模擬器上顯示一切正常
後來才知道
除了可以設定字體大小之外
iPhone 6/6P 還提供了 Zoom 的功能(註)
(分成一般顯示和 Zoom 顯示)
iPhone 6Plus 開啟 Zoom 模式,就等同 iPhone 6 的顯示方式
iPhone 6 開啟 Zoom 模式,就等同 iPhone 5S 的顯示方式
徹底解決這個問題的辦法
就是「不要用手機型號來決定解析度」
而是「用手機當下的顯示解析度」來決定如何顯示
程式碼如下:
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)
使用法如下:
if (IS_IPHONE_6P) {
….
}
else if (IS_IPHONE_6) {
…
}
註:這篇文章將 iPhone 的解析度解釋的非常清楚,大推