I'm just trying to plunge into the Objective-C event model on the iPhone, and looking at things that I fundamentally misunderstood here.
For experimental purposes, in viewviewDoadLoad controller mode, I set the text to UILabel, then sleep for two seconds, and then change the label text again.
My expectations are as follows: the label will read “First Text” first, then after two seconds it will be updated to read “Second Text”. Of course, this is not quite the way it happens. Instead, the view is not displayed at all for two seconds, and finally, when it becomes visible, its label reads "Second Text".
Can someone please explain to me what is going on? I am interested to know how you guys will achieve what I'm going to do here.
Greetings.
UPDATE 1 : here is the viewDidLoad method:
- (void)viewDidLoad { [super viewDidLoad]; label.text = @"First Label"; sleep(2); label.text = @"Second Label"; }
UPDATE 2 . I made a stupid mistake, so please ignore this update.
UPDATE 3 : I have now added the following to my viewDidAppear method:
- (void)viewDidAppear: (BOOL)animated { [super viewDidAppear: animated]; label.text = @"First Label"; sleep(2); label.text = @"Second Label"; }
Unfortunately, I have exactly the same problem.
UPDATE 4 : after the offers of gerry3 and Felix, I now implemented the Performer function and boom! Working! I will have to give it to gerry3, although he certainly does his best to help me. Thanks for all your contributions!
objective-c iphone
David foster
source share