setFont - warnings

Discussion in 'iOS Programming' started by Danneman101, Feb 23, 2009.

  1. Danneman101 macrumors 6502

    Aug 14, 2008
    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?
  2. caveman_uk Guest


    Feb 17, 2003
    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.
  3. Danneman101 thread starter macrumors 6502

    Aug 14, 2008
    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?

Share This Page