【问题标题】:what is the change required in this code to show text instead of image?此代码中显示文本而不是图像所需的更改是什么?
【发布时间】:2011-03-24 21:22:07
【问题描述】:

在我的 viewControllerOne 中,我正在使用 tableview..当我点击任何行时..我正在使用此代码..导航到另一个页面...

            Feches *rOVc = [[Feches alloc] initWithNibName:@"Feches" bundle:nil];     
            rOVc.hidesBottomBarWhenPushed = YES;
            rOVc.title  = [NSString stringWithFormat:@"15 March 2011"];
            rOVc.strURL = [[NSString alloc] initWithString:[[NSURL  fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"first_screen" ofType:@"png"]] absoluteString]];
            [self.navigationController pushViewController:rOVc animated:YES];
            [rOVc release];

现在当它导航到 Feches...

在获取的 viewdidload 中,我正在使用此代码...

NSString *html = [NSString stringWithFormat:@"<html><head>\
                  <meta id='viewport' name='viewport' content='minimum-scale=0.2; maximum-scale=5; user-scalable=1;' />\
                  </head><body style=\"margin:0\"><img id=\"yt\" src=\"%@\"></body></html>", self.strURL];

NSLog(@"html:%@",html);
// Load the html into the webview
if(self.myWeb == nil) {  
    self.myWeb = [[UIWebView alloc] initWithFrame:self.view.frame];  
    [self.view addSubview:self.myWeb];  
} 
[self.myWeb loadHTMLString:html baseURL:[NSURL URLWithString:self.strURL]];

这正在向我显示名为...first_screen 的图像,它位于我的图像文件夹中...

现在...我想使用文本段落而不是图像...但是使用相同类型的 html 和所有这些...任何人都可以建议我现在需要做哪些更改来显示段落而不是图片??

【问题讨论】:

    标签: iphone html ios uiimageview uitextfield


    【解决方案1】:

    更改您的 html 字符串内容。将&lt;img id=...&gt; 替换为&lt;p&gt;text&lt;/p&gt;

    您正在泄漏 UIWebView(如果 self.myWeb 保留)。将您的代码更改为:

    self.myWeb = [[[UIWebView alloc] initWithFrame:self.view.frame] autorelease];
    

    【讨论】:

    • ..好吧,如果我想在这个网页视图中显示像“blah blah blah”这样的文字,我应该改变什么......???
    • 正如我所写,将 IMG 标签替换为 P 标签,并将您的文本放在这两个 P 标签之间。
    猜你喜欢
    • 2013-12-03
    • 1970-01-01
    • 2017-11-01
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-14
    相关资源
    最近更新 更多