Question

Let's start with an example: when you enter the Contact program on your iPhone, then type on the TextField "Search", the keyboard is displaying itself and the tableView under is going dark (and deactivated). Then if I touch this dark deactivated list, the keyboard hides itself and the list becomes normal.

I would like to reproduce this functionality, but I don't know how. Is there a Cocoa method, or do I have to re-develop that by myself ?

Thanks for your advices.

Mart

Was it helpful?

Solution

I would even set the UIView to a uibutton so you can dismiss the keyboard when you want. Oh, That was there already!

OK, here's a bit of code that demonstrates how to add the button itself:

   CGRect frame = CGRectMake(0,
                                                      0,
                                                      [self parentViewController].view.bounds.size.width,
                                                      [self parentViewController].view.bounds.size.height);
    imageView = [[UIButton alloc] initWithFrame:frame];
    [imageView setAlpha:0];
    imageView.opaque = NO;
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:2];
    [imageView setAlpha:0.8];
    imageView.backgroundColor = [UIColor blackColor];
    [UIView commitAnimations];
    [imageView addTarget:self action:@selector(lockedScreenAction:) forControlEvents:UIControlEventTouchUpInside];

    [[self parentViewController].view addSubview:imageView];

OTHER TIPS

I'm pretty sure you are going to need to develop that for yourself. Looking at the effect on my phone, I think I would have a completely transparent (but black) UIView overlaying my UITableView. Register for the UIKeyboardWillShow notification, and when you receive it, animate the opacity of that UIView to 70%. Reverse the process on UIKeyboardWillHide.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top