2010-10-15 54 views
2

我只是試圖將我的文本textfield設置爲與詳細文本標籤顏色相同的顏色,這似乎是正確的方式來做到這一點,看到的東西提供這個答案在這裏,但我得到一個錯誤,有任何想法嗎 ?iPhone,txtPassword.textColor = cell.detailTextLabel.textColor; NSInternalInconsistencyException,原因:無效的參數不令人滿意:顏色?

txtPassword.textColor = cell.detailTextLabel.textColor; 

Assertion failure in -[UITextFieldLabel setTextColor:], /SourceCache/UIKit_Sim/UIKit-1262.60.3/UILabel.m:312 
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: color' 
+0

你用什麼方法設置顏色? detailTextLabel(已經)是否存在?我認爲你正在嘗試爲txtPassword的textColor設置nil。 – 2010-10-15 12:27:59

+0

在cellForRowAtIndexpath http://img.skitch.com/20101015-p66sexx9mudu1frhdtyh1d55wr.jpg – Jules 2010-10-15 12:45:04

回答

2

的這裏的問題是與cell.detailTextLabel.textColor detailTextLabel沒有爲UITableViewCellStyleDefault定義。

您可以通過嘗試直接設置顏色來確認問題是否存在於cell.detailTextLabel.textColor或其他內容中,即txtPassword.textColor = [UIColor blueColor];

+1

因此,他從標籤中得到的UIColor實際上是零,因此出現錯誤? – 2010-10-15 15:34:15

+1

我不確定..但我想失敗是由detailTextLabel未被定義觸發的。 – SegFault 2010-10-15 15:45:12

相關問題