开发者

Change font size according to the settings in iphone

开发者 https://www.devze.com 2023-01-15 23:20 出处:网络
I\'m trying to change the font size according to the setting changes. I used NSUserDefaults to keep the selected row as checked even if you relaunch the application. That is fine.. But when I\'m going

I'm trying to change the font size according to the setting changes. I used NSUserDefaults to keep the selected row as checked even if you relaunch the application. That is fine.. But when I'm going to change the font size in all pages according to that settings it is not changing immediately. It is changing if relaunch the app..

     Font settings page is a table view. When you select font size row it will navigate to the font size settings page. It will look like:
                 Small
                 Medium       
                 Large
      if you change size in 开发者_C百科this view that should effect immediately..

If any one help me that would be great help to me..

Thanks in advance


Your views are being laid out in viewDidLoad. The calculations that need to be done to render the view based on the font size are being done in this method as well. You probably have your app setup such that all of your views are loaded first, I am guessing a Tab Bar layout?

You will need to do 1 of two things to get this the way you want.

1) Setup an Observer, a Notification, or some method that is called when you change the font size. This function is then responsible for refreshing the views that need it.

2) Do Lazy loading for your views (only load them when needed) and tear them down when not needed. This means showing a loading screen in viewWillAppear, loading the view in viewDidAppear, and removing the view in viewDidDisappear.

While number 1 is probably easiest to implement, number 2 gives you an added bonus of keeping your memory size down. But depending on your complexity of your views, it could be an undesired effect. If I were you, I would use NSNotifications (#1) to notify all of your view controllers that the font size has changed. Then do what you need to do to redraw, alter the fonts on that controller.

0

精彩评论

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