开发者

Why is my UIView unresponsive after a reload?

开发者 https://www.devze.com 2023-01-14 15:36 出处:网络
I have a viewController that pops a modal view with a UIWebView.If I visit a particularly heavy page, I start getting memory warnings, followed by the parent view getting unloaded. This is all fine an

I have a viewController that pops a modal view with a UIWebView. If I visit a particularly heavy page, I start getting memory warnings, followed by the parent view getting unloaded. This is all fine and dandy, but when I close the modal view, my parent reloads (as expected) but is not longer able to process any touch events. The app responds to orientation changes correctly, but no amount of touching changes anything. Buttons don't work, a UIWebView doesn't respond to scrolling (but loads a default website), etc. It's as if there is a transparent UIView overlaying my entire window. Any ideas why this may occur?

Here's how I show the modal window:

BrowsingViewController* controller = [[BrowsingViewController alloc] 
    initWithNibName:UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ?     
    @"BrowsingViewController-iPad" : @"BrowsingViewController" 
      bundle:nil initialURL:[[request URL] absoluteString]];    
[self presentModalViewController:controller animated:YES];      
[controller release];

Here's how I dismiss it (from the modal view itself):

- (void) onCloseTouch
{   
    [self.parentViewController dismissModalViewControllerAnimated:YES]; 
}

EDIT:

Going through the view hierarchy, I don't notice anything out of the norm. Here are my log statements for the main view controller. They are identical both before and after I show my modal view:

viewWillAppear called.
=============== parentViewController subviews count=2
View [0] is a UINavigationTransitionView
subview count=0
View [1] is a UINavigationBar
subview count=2
      subview [0] is a UINavigationItemView
      subview [1] is a UINavigationButton
=============== self views subviews count=3
View [0] is a UIWebView with tag [1]
subview count=1
      subview [0] is a UIScrollView with tag [0]
View [1] is a UIToolbar with tag [2]
subview count=3
     开发者_如何学编程 subview [0] is a UIToolbarTextButton with tag [0]
      subview [1] is a UIToolbarButton with tag [0]
      subview [2] is a UIToolbarButton with tag [0]
View [2] is a UIView with tag [3]
subview count=2
      subview [0] is a UIActivityIndicatorView with tag [31]
      subview [1] is a UILabel with tag [32]

EDIT #2: This issue does not appear to occur on iPhone, just iPad. I have examined all places where I am performing a if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) and none of this logic appears to be of any consequence.


I wouldn't dismiss in that manner; I would use the delegate pattern instead: when BrowsingViewController wants to close, it calls something like [delegate browsingViewControllerDidFinish:self];. This is the "usual" way to dismiss the view controller, and it also eliminates the requirement that BrowsingViewController always be presented modally by its parent view controller.

What are the differences between the BrowsingViewController and BrowsingViewController-iPad xibs?

I would do some checking in the "parent" view controller, stepping through its view and all subviews to see if there's anything overlaid (as you say) atop the entire view hierarchy that is blocking the touch events.

0

精彩评论

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