santoshko / codenameone

Automatically exported from code.google.com/p/codenameone
0 stars 0 forks source link

Brief black screen dismissing keyboard on iOS. #553

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Sample code attached.

To reproduce:
Click on button to display dialog
Touch input field to display keyboard
Touch outside of field to dismiss keyboard
Screen flashes black

Touch input field to display keyboard
Enter text and click Done button in keyboard
Screen flashes black as dialog closes.

Everything has to be exactly right to reproduce this problem. The dialog must 
be displayed over a list, the list must be using a TextArea as part of a custom 
cell renderer, each entry must contain a couple of lines of text. However this 
sample code is based on a real world application. I have a database driven 
list, the user wants to search the database. It is while using the search 
dialog that they get the black screen flashes. It is a major part of the app 
and the black screens are very noticable.

The only way I have found to avoid the flashes is to remove the list from the 
form prior to displaying the model dialog. It works fine then but it looks 
strange having a modal dialog over a suddenly blank screen.

Original issue reported on code.google.com by mwarn...@readerware.com on 22 Feb 2013 at 10:09

Attachments:

GoogleCodeExporter commented 9 years ago
On which device this is happening? iPhone/iPod 3/4/5, iPad 2/3/4?

Original comment by shai.almog on 22 Feb 2013 at 1:49

GoogleCodeExporter commented 9 years ago
It is happening on an iPod 5G running iOS 6.1. It also happens on an iPod 3G 
running iOS 5.1.1.

I was describing behavior on the iPod 5G above. On the 3G it i a little 
different. The test app I submitted works normally, however in my real app I 
still have the problem. The fact that the test app works could be due to the 
smaller screen size, the dialog is moved to make way for the keyboard and moved 
back when the keyboard is dismissed. There is no flashing

The 3G screen size is smaller and in my app the dialog is virtually full 
screen. When I click outside the input field to dismiss the keyboard the 
background goes black. The dialog itself is unchanged but the list which is 
normally visible through the dialog has gone. It is now just a black background 
and stays that way until I close the dialog, then the list is restored.

Original comment by mwarn...@readerware.com on 22 Feb 2013 at 3:04

GoogleCodeExporter commented 9 years ago
Some more info which might help to track down the black screen problem: 

If the edited field is too low on screen then in CodenameOne_GLViewController's 
keyboardWillShow starts an animation to scroll viewFrame to fit the field on 
screen. And that is the point where you can reproduce - rotate device during 
the animation and the screen flashes black for a moment. 

Tested with iPhone 4 running iOS 7.

Original comment by jaanus_h...@hotmail.com on 28 Oct 2013 at 1:22

GoogleCodeExporter commented 9 years ago
A solution which helped me to avoid black-flashing when keyboard is dismissed 
after editing fields which are so low that frame scrolling is needed.

All I needed to do was to stop frameBuffer drawing while the animation 
triggered from keyboard hiding is running.
So I introduced a helper BOOL variable DRAWING_IS_TURNED_OFF in 
CodenameOne_GLViewController and checked in EAGLView.m's method 

- (BOOL)presentFramebuffer

that the method would not do anything when the DRAWING_IS_TURNED_OFF is true.
That is the current condition becomes:

if (![CodenameOne_GLViewController instance].DRAWING_IS_TURNED_OFF && context) {

And edit the end of the CodenameOne_GLViewController.m's method
- (void)keyboardWillHide:(NSNotification *)n
to this:

    //use an extra variable to turn of...
    self.DRAWING_IS_TURNED_OFF = YES;

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationDuration:0.3];
    [self.view setFrame:viewFrame];

    //and add animation end notification
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];

    [UIView commitAnimations];

and add a method to turn off the variable at the end of the animation:

- (void)animationFinished:(NSString *)animationID finished:(BOOL)finished 
context:(void *)context
{

    [CodenameOne_GLViewController instance].DRAWING_IS_TURNED_OFF = NO;
    repaintUI();
}

Original comment by jaanus_h...@hotmail.com on 13 Mar 2014 at 10:15