Dailycode.info

Short solution for short problems

First app in the App Store !!!

Yesterday the Wiezer app got approved in the app store. For now only in Dutch, but I plan to release a multi language (English en Dutch) app with some improvements soon.

Here the first review of the app looking good! Check in AppStore!

First app is a special feeling, next would be a second app that could reach and interest the whole world.


Wiezer

Today I posted my first app in the app store. The process was relative easy. Now just wait until the app is reviewed. The manual on the small cards game assistant app can be found here!

 


iOS: UITextView gets behind the keyboard

Very annoying problem when you make a simple view with on the bottom a UITextView. Reading a lot of solutions involving using a UIScrollview, I kept looking for an easy solution. And I found it.

The solution involves implementing the UITextView's delegate and moving up or down the view when the editing starts or ends.

Because the UITextView view doesn't have sent events like the UITextField, we need to implement the UITextViewDelegate .

Do not forget to set the delegate outlet for the TextView.

 

The rest is almost as easy:

#define kOFFSET_FOR_KEYBOARD 160.0

 

 

-(void) textViewDidBeginEditing:(UITextView *)textView

{

    if ([textView isEqual:self.txtRemark])

    {

        //move the main view, so that the keyboard does not hide it.

        if  (self.view.frame.origin.y >= 0)

        {

            [selfsetViewMovedUp:YES];

        }

    }

}

 

-(void) textViewDidEndEditing:(UITextView *)textView

{

    if ([textView isEqual:self.txtRemark])

    {

        if (self.view.frame.origin.y < 0)

        {

            [self setViewMovedUp:NO];

        }

    }

}

//method to move the view up/down whenever the keyboard is shown/dismissed

-(void)setViewMovedUp:(BOOL)movedUp

{

    [UIViewbeginAnimations:nilcontext:NULL];

    [UIViewsetAnimationDuration:0.3]; // if you want to slide up the view

    

    CGRect rect = self.view.frame;

    if (movedUp)

    {

        // 1. move the view's origin up so that the text field that will be hidden come above the keyboard

        // 2. increase the size of the view so that the area behind the keyboard is covered up.

        rect.origin.y -= kOFFSET_FOR_KEYBOARD;

        rect.size.height += kOFFSET_FOR_KEYBOARD;

    }

    else

    {

        // revert back to the normal state.

        rect.origin.y += kOFFSET_FOR_KEYBOARD;

        rect.size.height -= kOFFSET_FOR_KEYBOARD;

    }

    self.view.frame = rect;

    

    [UIViewcommitAnimations];

}

 

We will edit the field remark:

After clicking in the field, the screen moves up:

When finished (by clicking the hide keyboard sign, or by editing another field, the screen moves down again.