此文是接上文http://www.cnblogs.com/zzltjnh/archive/2013/05/15/3080058.html問題解決之後遇到的一個新問題,我的頁面上有一個UIScrollView和一個定時器用來記錄當前考試模式下的剩餘時間,問題出現了:當我滑動滾動試圖時,定時器的方法便不在運行(即被UI主線程阻塞)。google一下找到瞭解決辦法:將定時器放在非主線程中執行將更新UI的操作放到主線程,這樣UI主線程和定時器就能互不干擾的相互工作了,以下是主要代碼:
UILabel * NSTimer * @property (nonatomic, copy) NSString * @property (nonatomic, copy) NSString * @property (nonatomic, copy) NSString * hour = minute = second = totalSeconds = - ( - ( self = _lblShow = _lblShow.backgroundColor = _lblShow.font = [UIFont systemFontOfSize: _lblShow.textColor = _lblShow.textAlignment = _lblShow.numberOfLines = - ( (self = self.totalSeconds = minute * - ( _timer = [NSTimer scheduledTimerWithTimeInterval: - ( self.hour = _totalSeconds/ self.minute = _totalSeconds%/ self.second = _totalSeconds%% (_hour <= _lblShow.text = [NSString stringWithFormat: } _lblShow.text = [NSString stringWithFormat: - ( _hour = (_hour < self.strHour = [NSString stringWithFormat: } self.strHour = [NSString stringWithFormat: - ( _minute = (_minute < self.strMinute = [NSString stringWithFormat: } self.strMinute = [NSString stringWithFormat: - ( _second = (_second < self.strSecond = [NSString stringWithFormat: } self.strSecond = [NSString stringWithFormat: - ( _totalSeconds = - ( (_totalSeconds == self.totalSeconds -=