昨天用了下线程
m_alarmCount = 0;
[_alarmTableView reloadData];
_alarmActivity.hidden = NO;
_alarmStateLabel.hidden = NO;
[_alarmActivity startAnimating];
self.alarmStateLabel.text = [NSString stringWithFormat:@"获取状态中..."];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
int i = 0;
i = [m_logic getAlarmOutCount:m_StatusResult.devID count:&m_alarmCount];
i = [m_logic getAlarmOut:m_StatusResult.devID state:&m_alarmState];
dispatch_async(dispatch_get_main_queue(), ^{
if (m_alarmCount == 0) {
self.alarmStateLabel.text = [NSString stringWithFormat:@"该设备无报警输出通道"];
}
if (i != 0) {
self.alarmStateLabel.text = [NSString stringWithFormat:@"获取报警通道失败"];
}
if (i == 0 && m_alarmCount > 0) {
_alarmStateLabel.hidden = YES;
}
[_alarmActivity stopAnimating];
_alarmActivity.hidden = YES;
[_alarmTableView reloadData];
});
});
最开始把label放入全局异步中,发现无法进行UI更新,需拿出来才可,开发时需牢记:UI的更新只能写在主线程中,否则无法更新