遇到的問題:
以下兩種定制化UIBarButtonItem的代碼在iOS7下沒有問題:
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName :[UIColor darkGrayColor]} forState:UIControlStateNormal];
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{@
“UITextAttributeTextColor”:[UIColor darkGrayColor]} forState:UIControlStateNormal];
但是在iOS下打開一些系統自帶的ViewController(例如預覽pdf的QLPreviewController)的情況下遇到_UIRecordArgumentOfInvocationAtIndex異常。參照StackOverflow中類似情況的帖子,原來這應該是iOS SDK的一個Bug.以下簡單的改動就可以幫你解決問題,也許這種小插曲也是編程樂趣的一部分。
解決方法:
使用以下方式後問題就解決了:
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{UITextAttributeTextColor:[UIColor darkGrayColor]} forState:UIControlStateNormal];
參照網址:
http://stackoverflow.com/questions/14125378/uiappearence-support-for-ios-6-unexpected-results
http://stackoverflow.com/questions/19863972/mfmailcomposeviewcontroller-crashes-because-of-global-appearance-properties-on-i
http://stackoverflow.com/questions/22489828/adbannerview-crashes-app-when-it-is-clicked
http://stackoverflow.com/questions/12567708/monotouch-ios-6-crash-when-using-mfmailcomposeviewcontroller