将各种视图插入UIScrollView
我们试图为RSS类应用程序实现文章详细视图。窗口有一个UIScrollView,它包含一个UITextView(它是标题),一个UIButton(它将打开一个图库)和一个UIWebView(与正文一起)。这个想法是,所有这些元素一起滚动...将各种视图插入UIScrollView
问题是,只要我们有超过1000px高的身体,该标记下的所有内容都会被截断。我们已经听说这是因为这是视图的最大高度,并且由于Scroll由顶层的UIScrollView处理,所以没有办法看到进一步下降的情况。
有没有人知道解决这个问题的方法?
谢谢!
----更新1 ----
我们已经打破了体内转化为900px,高块,但第一个毕竟网页视图显示任何内容...
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; 
回答:
使用一个以上的UIWebViews中作为
是否使用loadHTMLString将内容添加到webView的身体吗? 尝试loadRequest方法。没有与1,024像素没有问题,当您使用的loadRequest
回答:
检查您的UIScrollView的contentSize。
我还没有听说过1000点的限制(或者在我的应用程序中看到它有更大的视图)。
回答:
我有同样的问题,我阅读并尝试了这个线程的一些技巧,但既不加载内容通过loadHTMLString,也没有使用[_webView setNeedsDisplay]确实改变了我的任何东西。 (我应该尝试加载更多UIWebViews中,但我懒惰:)
我用用滚动视图代表一个快速和肮脏的修复,其中的伎俩:
@interface ArticleViewController : UIViewController <UIScrollViewDelegate> 再火起来在初始化的看法
_scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; self.view = _scrollView; 
_scrollView.delegate = self; 
,并使用delgate的方法来重绘webView的,因为它显示了
- (void) scrollViewDidEndDragging: (UIScrollView *) scrollView willDecelerate: (BOOL) willDecelerate { 
    CGRect frame = _webView.frame; 
    frame.size = CGSizeMake(frame.size.width, frame.size.height + 1); 
    _webView.frame = frame; 
} 
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 
{ 
    CGRect frame = _webView.frame; 
    frame.size = CGSizeMake(frame.size.width, frame.size.height + 1); 
    _webView.frame = frame; 
} 
回答:
当你说:
我们试图打破身体分成几个900px高的网页视图,但第二,第三等得到削除(你可以看到的backgroundColor,而不是内容)...
在我看来,其他人已经遇到了这个问题(我再也找不到帖子了),实际上UIWebviews似乎只使用一个HTML解释器。这意味着如果一个UIWebView加载HTML内容,其他UIWebView将不加载任何内容。
为了解决这个问题,您需要使用UIWebView的委托方法:didFinishLoad,并在此之后开始加载其他网页浏览。
请注意,我不确定我在说什么,因为我没有自己尝试,但它可能是一个解决方案。
回答:
标记为答案的帖子在其最后的评论中有一个链接。这是解决这个问题的方法。我有这个问题,并调用[[webView _documentView] _webCoreNeedsDisplay];在那两位代表解决了它。干杯。
以上是 将各种视图插入UIScrollView 的全部内容, 来源链接: utcz.com/qa/260838.html



