how to put text in Webview?

10,861

Solution 1

If you really have to show the Text in an UIWebview implement a class which implements the UIWebView Delegate protocoll, like this:

@interface Web : UIViewController <UIWebViewDelegate> {
    UIWebView *webView;
    NSString *uRLString;

}

@property (nonatomic, retain) IBOutlet UIWebView *webView;
@property (nonatomic, retain) NSString *uRLString;

in your .m file you set the delegate and the view in your viewDidLoad like this:

self.view = webView.view;
self.webView.delegate = self;

and implement the openURL like this:

- (void)openURL:(NSString *)urlString
{
[myWebView loadHTMLString: <your static string in html-formate>]

}

But like I said before: You should use an UITextView to stick to Apple guidelines and you can also set preferences of UITextView without IB. In fact you really never HAVE to use the IB.

Solution 2

[webView1 loadHTMLString:@"Welcome to StackOverFlow" baseURL:nil];  

Solution 3

[myWebView loadHTMLString:@"<p>I stand here today humbled by the task before us, grateful for the trust you have bestowed, mindful of the sacrifices borne by our ancestors. I thank President Bush for his service to our nation, as well as the generosity and cooperation he has shown throughout this transition</p>"]
Share:
10,861
Jean-Luc Godard
Author by

Jean-Luc Godard

Nothing is original. Steal from anywhere that resonates with inspiration or fuels your imagination. Devour old films, new films, music, books, paintings, photographs, poems, dreams, random conversations, architecture, bridges, street signs, trees, clouds, bodies of water, light and shadows. Select only things to steal from that speak directly to your soul. If you do this, your work (and theft) will be authentic. Authenticity is invaluable; originality is non-existent. And don’t bother concealing your thievery - celebrate it if you feel like it. In any case, always remember what Jean-Luc Godard said: “It’s not where you take things from - it’s where you take them to.

Updated on June 04, 2022

Comments

  • Jean-Luc Godard
    Jean-Luc Godard almost 2 years

    I have this kind of 4 paragraphs.

    like this:

    I stand here today humbled by the task before us, grateful for the trust you have bestowed, mindful of the sacrifices borne by our ancestors. I thank President Bush for his service to our nation, as well as the generosity and cooperation he has shown throughout this transition.

    I want to use this paragraphs in different views using webview.

    I mean I want to show such paragraphs in UIWebview

    can anyone please tell me how to do this?

    • Amandir
      Amandir about 13 years
      Do you have a website displaying these paragraphs? UIWebview is ment to display webcontent. If you just want to present static text you should use an UITextView.
    • Jean-Luc Godard
      Jean-Luc Godard about 13 years
      yes static text...But I can't use IB Also...plus I have to make some html...and using that I have to show this