开发者

Refresh/reload view after syncing on the Internet

开发者 https://www.devze.com 2023-01-10 01:46 出处:网络
I\'m writing iPhone application which periodically is syncing with the synchronization web service. Everything works ok, but unfortunately after synchronization user do not see any changes in the view

I'm writing iPhone application which periodically is syncing with the synchronization web service. Everything works ok, but unfortunately after synchronization user do not see any changes in the view if he visited it before.

I need to force to reload/refresh some of views. How could I do that with for example viewWillAppear method?

I've tried something like this in one of my view controllers:

-(void) viewWillAppear:(BOOL)animated   
{
        NSArray* sbw = [self.view subviews];

        UIView* view;
        for (view in sbw) 
        {
            [view setNeedsDisplay];
        }

        [self.view setNeedsDisplay];
        [super viewWillAppear];

    }

But the subviews are not refreshing. Is there any method for forcing to reload/refresh view?

I know that开发者_C百科 viewWillAppear is executed when I move to this view but it's not refreshing - so how can I do that?


in tableviews you could use : [tableView reloadData]; to reload a tables content. If you just want to update the views content you could just change it. Lets say if you have a view class and a controller class MyUIView and MyUIViewController and MyUIView does contain an UILabel * myLabel you could change the label text inside the controller by:

[((MyUIView *)self.view).myLabel setText:@"This is a new text."];

so no need for forcing update.


You can write the method "viewWillAppear" in that you can write your code to be reloaded which may take the data from your data base.This method will be executed when ever the view starts to load.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号