Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Resizing UIView at Runtime / No Longer Receiving Scroll Events
At runtime, I have a UIView (ViewA) that contains a UIWebView and a UITextField. In its normal (non-typing) state, the UIView takes up about 1/3 of the screen. On entering the text field, I need to not only display the keyboard, but make the UIView fill the screen (covering another UIView (ViewB) containing another UIWebView.
- (void)keyboardWasShown:(NSNotification *)notification { // Get the size of the keyboard. Requires iOS 3.2 or higher float keyboardHeight = [self getKeyboardHeight:notification];
[self animateView:-keyboardHeight];
}
That seems to do the right thing visually (ViewA expands to the right dimensions and the UIWebView in ViewA displays properly) but the UIWebView in ViewA no longer responds to any events (scrolling, etc). In fact, the UIWebView in ViewB, even though it's under ViewA, is getting the touch events.
Based on my searching, I'm pretty sure it's something I've done incorrectly with setting the frame in animateView:, but can't for the life of me figure out what it is.
At runtime, I have a UIView (ViewA) that contains a UIWebView and a UITextField. In its normal (non-typing) state, the UIView takes up about 1/3 of the screen. On entering the text field, I need to not only display the keyboard, but make the UIView fill the screen (covering another UIView (ViewB) containing another UIWebView.
- (void)keyboardWasShown:(NSNotification *)notification { // Get the size of the keyboard. Requires iOS 3.2 or higher float keyboardHeight = [self getKeyboardHeight:notification];
[self animateView:-keyboardHeight];
}
That seems to do the right thing visually (ViewA expands to the right dimensions and the UIWebView in ViewA displays properly) but the UIWebView in ViewA no longer responds to any events (scrolling, etc). In fact, the UIWebView in ViewB, even though it's under ViewA, is getting the touch events.
Based on my searching, I'm pretty sure it's something I've done incorrectly with setting the frame in animateView:, but can't for the life of me figure out what it is.
Any guidance is appreciated.
In general, I would suggest shifting everything up rather than resizing your views. The keyboard shifts up from the bottom, and it makes visual sense if the view controller's content view shifts up too. It just looks like the keyboard is pushing everything up.
As to your code, I'm not sure what's causing the problem. I do have a test to run though.
Comment out all the animation code, and just change the view's frame directly. See if the web view scrolls correctly.
By default, the system turns off user interaction while an animation is running. I'm wondering if your code is leaving an animation i place. By getting rid of the animation code we can test that hypothesis.
Regards,
Duncan C WareTo
Animated GIF created with Face Dancer, available for free in the app store.
Thanks for the fast response! I tried your suggestion of disabling the animation and just setting the frame directly, but the result was the same -- the UIWebView in ViewA doesn't get the touch events (ViewB is getting them). I wish I could just shift the UIView up without resizing it, but the UI/UX designers are requiring the full-screen view, and unfortunately the size of the UIView is a different size when the keyboard is hidden vs. when the keyboard is displayed (according the the requested design).
I've seen some indications online that there are problems with resizing UIScrollViews (and by relation, UIWebViews) and events, but haven't seen any reasonable solutions.
As a test, I tried your suggestion of not resizing the view and just allowing the keyboard to push it up, and strangely, the result is still the same -- after the keyboard appears, the UIWebView in ViewA still does not get the events. Now I'm really stumped...
Replies
As to your code, I'm not sure what's causing the problem. I do have a test to run though.
Comment out all the animation code, and just change the view's frame directly. See if the web view scrolls correctly.
By default, the system turns off user interaction while an animation is running. I'm wondering if your code is leaving an animation i place. By getting rid of the animation code we can test that hypothesis.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI've seen some indications online that there are problems with resizing UIScrollViews (and by relation, UIWebViews) and events, but haven't seen any reasonable solutions.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome