我用导航栏实现了UIWebview,任何新访问的页面都会添加到导航堆栈中,但问题是,当我在推送新视图之前隐藏了一些元素并返回到同一页面时,即使我再次显示,元素也会保持隐藏状态
这是我的JS代码
jQuery(document).ready(function(){
$('#hello').fadeIn('slow');});
$('.facebook,.location, .mainItem').hide();
$('.facebook,.location, .mainItem').show();
$('.contactIcon').click(function(e){
e.preventDefault();
$('.facebook,.location, .mainItem').fadeOut('slow', function() {
window.location = "contact.html";
});
});
这是Objective-C代码
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
DrillDownWebExampleAppDelegate *appDelegate =
(DrillDownWebExampleAppDelegate *)[[UIApplication sharedApplication] delegate];
if(navigationType == UIWebViewNavigationTypeOther)
{
NSURL *url2 = [request URL];
NSString *URLStr = [url2 absoluteString];
RootViewController* viewController = [[RootViewController alloc] init];
NSString *holder = [self getQueryStringInner:URLStr];
[self getQueryString:URLStr];
if([holder length] != 0 )
{
appDelegate.title =@"Title";
appDelegate.query = queryString;
[self.navigationController pushViewController:viewController animated:YES];
[viewController release];
return NO;
}
}
return YES;
}
你能帮忙吗?
我做了一个小把戏,但我认为还有另一种方法
我在window.location 之后再次展示了元素
jQuery(document).ready(function(){
$('#hello').fadeIn('slow');});
$('.facebook,.location, .mainItem').hide();
$('.facebook,.location, .mainItem').show();
$('.contactIcon').click(function(e){
e.preventDefault();
$('.facebook,.location, .mainItem').fadeOut('slow', function() {
window.location = "contact.html";
$('.facebook,.location, .mainItem').show();
});
});
它的工作原理与类似