[問題]如何將 label的值傳到glow label

作者: ye4598712 (策馬天下)   2014-03-03 10:17:44
小弟目前遇到一點小問題
就是我用sensor去掃描時
我想把值傳回來
那目前我的值是有傳到R(0000)
ex:sensor是有徵測到R的顏色值是1500
那回傳的值就是R(1500)
那我想說該如何在回傳到glow label裡
變成說 R 如果掃到是1200
而回傳出現也是R(1200)
而glow label 也是出現1200
我目前是用button的方式glow label才會出現0000
那如果我不用button的方式
而是我按外部裝置的一個鍵 讓他去讀要怎麼做??
(目前只能在R(0000)會一直變換數字
而glow label則沒有動作)
http://ppt.cc/3YAx
butto按下去的程式碼
- (IBAction)b1:(id)sender {
_glow.text=self.RValue.text;//表格內容=文字的內容
// [_glow setText:[NSString stringWithFormat:@"%04d", (int)[self.RValue.text intValue]]];//字串轉整數
[_glow setText:[NSString stringWithFormat:@"%04d", (int)[self.RValue.text intValue]]];
}
R(0000)部分的程式碼
- (void)sensorTagDidUpdateColorSensor:(int16_t *) rgb //rgb給16bits
{
int16_t r,g,b;
r=rgb[0];
g=rgb[1];
b=rgb[2];
self.ColorSensor_R_View.normalizedReading = ((float)r)/4096; //長度條(單位4096)
self.ColorSensor_G_View.normalizedReading = ((float)g)/4096;
self.ColorSensor_B_View.normalizedReading = ((float)b)/4096;
self.RValue.text=[NSString stringWithFormat: @"R(%04d):", r]; //數字(4位數整數值)
self.GValue.text=[NSString stringWithFormat: @"G(%04d):", g]; //數字(4位數整數值)
self.BValue.text=[NSString stringWithFormat: @"B(%04d):", b]; //數字(4位數整數值)
}
作者: johnlinvc (阿翔)   2014-03-03 17:45:00
ui只能在main thread裡改,用 dispatch async 試試
作者: ye4598712 (策馬天下)   2014-03-06 15:34:00
不怎麼懂,可以再詳細解說下嗎?

Links booklink

Contact Us: admin [ a t ] ucptt.com