NSButton的标题在setAttributedTitle上消失:

时间:2018-03-22 15:49:36

标签: objective-c cocoa nsattributedstring appkit

执行此代码按钮后,标题有时会消失,但并非总是如此。什么可以解决这个问题?

Serial_Number   Gateway_Uptime  Defrost_Cycles  Freeze_Cycles   Float_Switch_Raw_ADC    Bin_status  Line_Voltage    ADC_Evaporator_Temperature  Mem_Sw  Freeze_Timer    Defrost_Timer   Water_Flow_Switch   ADC_Mid_Temperature ADC_Water_Temperature   Ambient_Temperature Mid_Temperature Water_Temperature   Evaporator_Temperature  Ambient_Temperature_Off_Board   Ambient_Temperature_On_Board    ADC_Ambient_Temperature Control_State   Compressor_Runtime  temp_sensor temp_pcb    gw_uptime   winc_fw gw_fw_version   gw_fw_version_git   gw_sn   heap_free   gw_sig_csq  gw_sig_quality  wifi_sig_strength   wifi_resets LastModifiedDateUTC Defrost_Cycle_time  Freeze_Cycle_time
12345   251402  540 494 106 0   98  158 113 221 184 0   0   0   1259    1259    1259    33  0   0   0   Freeze  10833   0   78  251402  19.5.4  0.0.0   2a75f20-dirty   328.00000000    10976   0   0   -61 0   2018-03-20 11:15:28.000 0   0
12345   251702  540 494 106 0   98  178 113 517 184 0   0   0   1259    1259    1259    22  0   0   0   Freeze  10838   0   78  251702  19.5.4  0.0.0   2a75f20-dirty   328.00000000    10976   0   0   -62 0   2018-03-20 11:15:42.000 0   0
...

1 个答案:

答案 0 :(得分:0)

NSButton有一个' On'州和“关”' state,.attributeTitle是指' Off'中的标题。 state和.attributeAlternateTitle是' On'中的标题。状态,所以你必须设置两者。

https://developer.apple.com/documentation/appkit/nsbutton