TimOliver / TOWebViewController

A view controller class for iOS that allows users to view web pages directly within an app.
http://www.timoliver.com.au/2014/07/27/towebviewcontroller-an-open-source-web-viewer-for-ios/
Other
1.48k stars 211 forks source link

WrongTitle when come back from other View Controller #85

Closed maimake closed 8 years ago

maimake commented 8 years ago

I push a view controller from TOWebViewController, and then pop to TOWebViewController, the title becomes "Loading...", actually, the web view is completed!

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    //Show placehodler title until we work out the new one
    [self showPlaceholderTitle]; //<===== wrong here 
    ...
}

- (void)showPlaceholderTitle
{
    //set the title to the URL until we load the page properly
    if (self.url && self.showPageTitles && self.showUrlWhileLoading) {
        NSString *url = [_url absoluteString];
        url = [url stringByReplacingOccurrencesOfString:@"http://" withString:@""];
        url = [url stringByReplacingOccurrencesOfString:@"https://" withString:@""];
        self.title = url;
    }
    else if (self.showPageTitles) {

    //===== wrong here ======
    //you should check the current page real status
        self.title = NSLocalizedStringFromTable(@"Loading...", @"TOWebViewControllerLocalizable", @"Loading...");
    //===== wrong here ======
    }
}
TimOliver commented 8 years ago

Hi @maimake! Sorry for the delay!

Um, I'm a bit confused. Are you saying your page is already loaded before the view has appeared and this is upsetting the ordering?

I'll see about moving the [self showPlaceholderTitle]; to an earlier point in the view controller's life cycle!

TimOliver commented 8 years ago

I pushed a new version that moved the default page title to viewDidLoad. This should fix that issue! :)