开发者

iPhone: How to show UIWebview on top of UITableView?

开发者 https://www.devze.com 2023-04-03 01:59 出处:网络
In my Universal app which supports IOS4 and later, I have a UINavigationController and pushing UITableViews using UITableViewController.

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 开发者_StackOverflow社区do this any ideas?


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?


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; 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号