Configuring the contents of an Inset in a UITableView after returning from another topic

How to set content tab in UITableView after returning from a separate stream?

Here is some code to get the gist of what I'm doing, feel free to offer suggestions outside the scope of this question.

My main goal is to collapse the area that the webview will go into (the area above the table created using the contentInset) if there is no advertisement.

//In View did Load
[NSThread detachNewThreadSelector:@selector(getBannerAdContent) toTarget:self withObject:nil];


-(void)getBannerAdContent
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSString *html = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://192.168.0.18:83/PhotoGalleryService.svc/LoadBannerAd/"]];
    [self performSelectorOnMainThread:@selector(loadBannerAd:) withObject:html waitUntilDone:NO];
    [pool release];
}


-(void)loadBannerAd:(NSString*)html
{
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 2, 300, 40)];

    [webView loadHTMLString:html baseURL:nil];
    webView.delegate = self;
    webView.scalesPageToFit = NO;
    webView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin);
    [self.view addSubview:webView];
    [webView release];
    UITableView *myTableView = (UITableView*)[self.view.subviews objectAtIndex:0 ];
    //The following line is doing nothing.
    myTableView.contentInset = UIEdgeInsetsMake(44,0.0,0,0.0);
}

Any help you can give me would be greatly appreciated.

EDIT: A bit more detailed explanation ...

In my opinion, I booted up, a spark separate stream. This thread downloads html from the i service configured, and then installs it in webview. However, as I step over before he gets on the line

myTableView.contentInset = UIEdgeInsetsMake(44,0.0,0,0.0);

, .

,

+3
2

contentInset , , . contentInset contentOffset, , , .

myTableView.contentOffset = CGPointZero;
+5

Swift5 UITableView

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    if shouldAddContentInset {
        tableView.contentInset = UIEdgeInsets(top: 100, left: 0, bottom: 0, right: 0)
        tableView.contentOffset = CGPoint(x: 0, y: -tableView.contentInset.top)
    }
}

- :

func gotResponseFromSomewhere() {
    shouldAddContentInset = true
    viewDidLayoutSubviews()
}
0

Source: https://habr.com/ru/post/1788040/


All Articles