将各种视图插入UIScrollView [英] inserting various views into UIScrollView

查看:77
本文介绍了将各种视图插入UIScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试为类似RSS的应用程序实现文章详细信息视图。窗口具有一个UIScrollView,该UIScrollView包含一个UITextView(即标题),一个UIButton(用于打开图库)和一个UIWebView(具有主体)。这个想法是所有这些元素一起滚动...

we're trying to implement an article detail view for an RSS-like application. The windows has a UIScrollView that contains a UITextView (which is the title), a UIButton (which opens a gallery), and a UIWebView (with the body). The idea is that all these elements scroll together...

问题是,只要我们的身体高度超过1000px,该标记以下的所有内容都会被截断。我们听说这是因为这是视图的最大高度,并且由于Scroll是由顶部UIScrollView处理的,因此无法查看进一步的下降。

The problem is that whenever we have a body over 1000px tall, everything below that mark is truncated. We've heard that this is because that is the maximum height for a view, and since the Scroll is handled by the top UIScrollView, there is no way to see what's further down.

有人知道这种方法吗?

谢谢!

----更新1- ---

---- update 1 ----

我们已经将主体分解为900px高的块,但是第一个之后的所有Webview都没有显示内容...

We've broken up the body into 900px-high chunks, but all webviews after the first one show no content...

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;


推荐答案


  1. 使用还有一个UIWebViews作为主体

  1. Use more then one UIWebViews as body

您是否使用loadHTMLString向webView添加内容?
尝试loadRequest方法。使用loadRequest

Are you using loadHTMLString to add content to webView? Try loadRequest method. There is no problem with 1024px when you are using loadRequest

这篇关于将各种视图插入UIScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆