문제

I want customised navigation bar with custom views, which I have done successfully.

Labels are also used in it, now I want to change label text after some time, but it is showing very strange behaviour, It does not change value of label, not even remove it from superView. but sometimes it work just after few seconds the code execute. or work after several attempts (I am running timer to change values).

I don't know if it is strange behaviour from iOS SDK or may be there some more appropriate way to do this??

I also used tag but no success

  for(UILabel *view in subViews)
  {
       if (view.tag == 1)
       {
           view.text = @"someVal";
       }
       else if (view.tag == 2)
       {
           view.text = @"someVal2";
       }
       else if (view.tag == 3)
       {
           view.text = @"someVal3";
       }
   }
도움이 되었습니까?

해결책

If you are using background thread, then you have to come back on main thread to update UI,,

dispatch_async(dispatch_get_main_queue(), ^{
   //block to be run on the main thread
   [self.tableView reloadData];
 });
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top