Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
Im trying to set the fontsize of my uiwebview (ie. the content there) by using this code:

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?
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
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.
 

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
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?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.