質問

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