【发布时间】:2009-07-23 20:50:33
【问题描述】:
我们正在尝试为类似 RSS 的应用程序实现文章详细信息视图。窗口有一个 UIScrollView,其中包含一个 UITextView(它是标题)、一个 UIButton(它打开一个画廊)和一个 UIWebView(带有正文)。这个想法是所有这些元素一起滚动......
问题是,每当我们的身体超过 1000 像素高时,低于该标记的所有内容都会被截断。我们听说这是因为这是视图的最大高度,而且由于 Scroll 是由顶部的 UIScrollView 处理的,因此无法看到更下方的内容。
有人知道解决办法吗?
谢谢!
---- 更新 1 ----
我们已将正文分成 900 像素高的块,但第一个之后的所有 webview 都没有显示内容...
UIScrollView *scroll=[[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
[scroll setBackgroundColor:[UIColor whiteColor]];
[scroll setCanCancelContentTouches:NO];
scroll.clipsToBounds = NO;
scroll.indicatorStyle = UIScrollViewIndicatorStyleBlack;
//Título
CGRect tit =CGRectMake(5.0f, 0.0f, 315.f, 50.0f);
UILabel *titulo=[[UILabel alloc] initWithFrame:tit];
titulo.text=[itemNew objectForKey:@"titulo"];
titulo.numberOfLines = 2;
titulo.font=[UIFont fontWithName:@"Helvetica" size:16.0f];
titulo.textColor=[self getColor:@"00336E"];
[scroll addSubview:titulo];
[titulo release];
//Entradilla
float altura_entradilla=calcLabel([itemNew objectForKey:@"entradilla"], [UIFont boldSystemFontOfSize:16], 50, 315.0f);
CGRect ent_frame = CGRectMake(5.0f, 50.0f, 315.0f,altura_entradilla );
UILabel *entradilla=[[UILabel alloc] initWithFrame:ent_frame];
entradilla.text=[itemNew objectForKey:@"entradilla"];
entradilla.numberOfLines=4;
entradilla.font=[UIFont fontWithName:@"Helvetica" size:17.0f];
entradilla.textColor=[UIColor blackColor];
[scroll addSubview:entradilla];
[entradilla release];
NSString *cuerpo=[itemNew objectForKey:@"cuerpo"];
[scroll setContentSize:CGSizeMake(320.0f,40000.0f)];
[scroll setScrollEnabled:YES];
webView = [[UIWebView alloc] initWithFrame:CGRectMake(5.0f, altura_entradilla+50, 315.0f, 900)];
[webView loadHTMLString:cuerpo baseURL: [NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath]]];
webView.detectsPhoneNumbers=NO;
webView.delegate=self;
[webView setScalesPageToFit:NO];
[scroll addSubview:webView];
webView.backgroundColor=[UIColor blackColor];
webView.userInteractionEnabled=NO;
[webView release];
if (altura_webview>900) {
UIWebView *webView2 = [[UIWebView alloc] initWithFrame:CGRectMake(5.0f, altura_entradilla+50+900, 315.0f, 900)];
[webView2 loadHTMLString:cuerpo baseURL: [NSURL fileURLWithPath:[[NSBundle mainBundle] resourcePath]]];
webView2.detectsPhoneNumbers=NO;
webView2.delegate=self;
[webView2 setScalesPageToFit:NO];
[scroll addSubview:webView2];
webView2.backgroundColor=[UIColor yellowColor];
webView2.userInteractionEnabled=NO;
[webView2 release];
}
self.view=scroll;
【问题讨论】:
-
我不知道这是否可行,但是是否可以将 UIText 和 UIButton 插入到 UIWebView 中?
-
WebView 有 webView.userInteractionEnabled=YES;以便所有视图通过 UIScrollView 一起滚动。