Objective-C UIWebview 和 UITableView 滚动高度

Objective-C UIWebview and UITableView scroll height

我在应用程序中使用 UIWebView 和 UITableView 时遇到问题。我不明白为什么我不能在列表底部滚动:它总是缺少几个点来滚动到底部(看看下面的模型)。

在我所有的屏幕中,顶部都有一个固定标签,下面有一个 UIScrollView 或 UIWebView 或 UITableView,我认为这可能是问题的根源。我尝试更新视图高度或滚动高度但它不起作用...

我制作了一个模型来向您展示我的应用程序屏幕的样子:http://i.imgur.com/mTWsdOU.jpg 如您所见,文本在底部被截断了,因为我无法滚动到底部...

任何人的帮助将不胜感激。提前致谢!

在视图中滚动可以,但它不能让我完全向下滚动...

这是我的代码示例:

#import "Constants.h"

@implementation ContentController {

- (void)viewDidLoad {

   [super viewDidLoad];

   self.windowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
   self.windowView.backgroundColor = [UIColor whiteColor];


   // Bandeau titre

   UILabel* titre =[[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
   titre.font = FONT_RALEWAY_BOLD(18);
   titre.backgroundColor = MAIN_BLUE;
   titre.textColor = [UIColor whiteColor];
   titre.textAlignment = NSTextAlignmentCenter;
   titre.text = @"Test";

   [self.windowView addSubview:titre];

   [self createWebViewWithHTML];
   self.webView.delegate = self;

   [self.windowView addSubview:self.webView];

   self.view = self.windowView;

}


- (void) createWebViewWithHTML{
     NSMutableString *html = [NSMutableString stringWithString: @"<html><head><title></title></head><body style=\"background:transparent; padding:0px; margin:15px 15px;\">"];

    [html appendString: content];

    [html appendString:@"</body></html>"];

    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 50, SCREEN_WIDTH, SCREEN_HEIGHT)];

    [self.webView setBackgroundColor:[UIColor clearColor]];

    NSString *path = [documentsDirectory stringByAppendingString:@APP_IMAGES_DIR];
    NSURL *baseURL = [NSURL fileURLWithPath:path];

    [self.webView loadHTMLString:html baseURL:baseURL];
}

如果您尚未设置 scrollEnabled,则必须将其设置为 YES。

并设置内容大小。请记住,内容大小高度应大于框架高度。

如果你能贴上代码,那将有助于给出更具体的答案

解决方案很简单...如果导航栏下有固定内容,只需降低 UIWebView 或 UITableView 的高度即可。

对于 UIWebView :

self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 50, SCREEN_WIDTH, SCREEN_HEIGHT-(self.navigationController.navigationBar.frame.size.height + 50))];

对于 UITableView :

self.tabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 50, SCREEN_WIDTH, SCREEN_HEIGHT-(self.navigationController.navigationBar.frame.size.height + 50))];