2
votes

I have a weird bug. I have a grouped UITableView with static cells and I want to add a white shade under each section. The way I thought about doing it is to add a shadow to each lowest cell in a section.

So in viewDidAppear (because in viewDidLoad it wouldn't work) I wrote:

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// change the cells shadow

The problem is that in viewDidLoad I call becomeFirstResponder on a text field. When cellForRowAtIndexPath is called, the textfield looses focus.

I tried using becomeFirstResponder in viewDidAppear after the call to cellForRowAtIndexPath but that doesn't help, the textfield still looses focus.

How can I fix this?

2

2 Answers

4
votes

I recommend you to use the tableView:willDisplayCell:forRowAtIndexPath: method for adding the shadow.

2
votes

Use the following code.

[textfield performSelector:@selector(becomeFirstResponder) withObject:nil afterDelay:0];