在iOS中重绘视图 [英] Redrawing a view in ios

查看:73
本文介绍了在iOS中重绘视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以重绘整个视图.

Is it possible to redraw the whole view.

我需要它来完成我的语言设置.问题在于,只有在再次绘制视图之后,语言才会更改.就像您退出设置然后再次进入一样,然后更改了语言.但是,一旦您保存了所有内容,语言就会保持不变.

I need it to complete my language settings. The problem is that the language only changes after the views there drawn again. Like you go out of settings and then go in again, then the language is changed. But the moment you save everything, the language stays the same.

在发现语言更改后,我应该如何重画视图,或者最好是重新绘制整个应用程序?

So how should i redraw my views, or by best the whole app, after the language change was found?

推荐答案

在ARC中:

- (void)setLanguage:(LanguageType)languageType
{
    _language = languageType;

    //TODO:your settings

    [_theWholeView setNeedsDisplay];
}

如果这不起作用,则有一个非常麻烦的解决方案,它可以重新加载整个视图.

If that can not work , there is a very troublesome solution , it can reload the whole view.

您可以这样编码: 在view.h中,您需要创建一个委托. @protocol WholeViewDelegate

You can code like this: In the view.h , you need creat a delegate. @protocol WholeViewDelegate

- (void)reloadData;

@end

在视图中.m

- (void)setLanguage:(LanguageType)languageType
{
    _language = languageType;

    //TODO:your settings

    [_delegate reloadData];
}

在控制器中,您需要实现委托 在控制器中.m

In the controller you need to implement the delegate In the controller.m

- (void)reloadData
{
    if(_wholeView)
    {
        [_wholeView removeFromSuperview];
    }
    // in the wholeView init method you should refresh your data
    _wholeView = [[WholeView alloc] init];
    self.view addSubview:_wholeView
}

这篇关于在iOS中重绘视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆