View Full Version : setFont - warnings

Feb 23, 2009, 05:52 AM
Im trying to set the fontsize of my uiwebview (ie. the content there) by using this code:

[webView setFont:[UIFont size:30]];

However, my app freezes, and I get the following warning (no error, though):

"warning: 'UIFont' may not respond to '+size:'
(Messages without a matching method signature will be assumed to return 'id' and 'accept'...' as arguments.)
warning: 'UIWebView' may not respond to '-setFont'."

Any idea what Im doing wrong here?

Feb 23, 2009, 06:00 AM
It's because size is not a class method of UIFont - which is what the error is telling you. The method you're looking for is systemFontOfSize:

Also setFont: is not a method of UIWebView. I don't know if you can do what you're trying to do there. Maybe you should try reading the class documentation rather than trying to make up your own imaginary methods? Simply guessing the method names is probably not a successful strategy.

Feb 23, 2009, 06:41 AM
No, your right, webview does not support fontsize, so this seems to be impossible.

Im trying to implement a way to extract an integer-variable from the systems settings (using Root.plist and NSUserDefaults) and setting it as the font-size of my uiwebviews.

Since setting the uiwebviews' fontsize directly seems impossible, the other solution would be to extract the fontsize-integer from Root.plist, and then using a javascript from each webpage loaded into the webview alter the <body>-tag's css-property for font-size. Very tedious as opposed to my "imaginary" method that I tried out.

Only pitfall is that I dont know how to get the objc-integer (containing the fontsize) from the html-page's javascript-code. Any ideas?