Spring
Spring

Reputation: 11835

iPhone: How to show UIWebview on top of UITableView?

In my Universal app which supports IOS4 and later, I have a UINavigationController and pushing UITableViews using UITableViewController.

Some pages may need to show some messages in HTML so I wanna use WebView. So I imagined like this;

When a new tableview is pushed I will check if it needs to show any messages if yes the new window will open up with a webview on top of the tableview covering maybe %80 of the screen and the tableview is disabled at that moment, when user is done reading the webview they will close it and tableview will be get activated again. Also there will be a message icon on the navigation bar to re-open and re-read the messages again.

How can I do this any ideas?

Upvotes: 0

Views: 722

Answers (2)

Nielsou Hacken-Bergen
Nielsou Hacken-Bergen

Reputation: 2626

you can use [[cell contantView] addSubview:aWebView].

For instance, you have a boolean : iMustShowAWebView

in cellforrowatindexpath

if (iMustShowAWebView) {
     [[cell contantView] addSubview:aWebView]
}

in heighForRowAtIndexPath

if (iMustShowAWebView)
     return 44;
 else 
     return 0; 

Upvotes: 0

ader
ader

Reputation: 5393

present the webview modally when the tableview appears:

create your viewcontroller (that has a webview):

UIViewController *webUIViewController = [[UIViewController alloc] init];

locate the navigation controller:

UINavigationController *myNavController = [self navigationController];

present your webview modally:

[myNavController presentModalViewController:webUIViewController animated:YES];

I'd probably only do this for web documents stored locally in the apps bundle though - as you want the user to get feedback of any network loading and what if they have no internet access?

Upvotes: 1

Related Questions