views:

48

answers:

2

The cells in my tableview are horizontal UIScrollViews, which I assume is the reason didSelectRowAtIndexPath is not being called. I have my resignFirstResponder call in that method.

Does anyone have an easy way for me to fix this? Is there an alternative to didSelectRowAtIndexPath? Or is there a way to get that method to fire?

Thanks!

+1  A: 

You are probably still using cellForRowAtIndexPath and probably you have UIScrollView as subviews of the cell's contentView. Can you just call a method up the superview chain, i.e. [self.superview method], [self.superview.superview method]? That should at least get you back to the UITableView object and if necessary you could identify your UIScrollViews by tag.

Adam Eberbach
Actually, it's even simpler than that. But you gave me the idea. I just override touchesBegan on the UIView inside one of my UIScrollView pages and then go up the chain like you suggested. Thanks for the eye opener! Cheers.
Mike A
Actually, it wasn't as simple as that. I came up with a pretty elegant solution though, thanks again.
Mike A
A: 

So to solve this little problem of mine, I came up with a quick method you can implement in your AppDelegate.

- (void)setFirstResponder:(UISearchBar *)setResponder{  
    responder = setResponder;   
}

- (void)unsetFirstResponder{        
    if(responder){
        [responder resignFirstResponder];
        responder = nil;
    }   
}

Then whenever you call the first responder

[(yourAppDelegate *)[[UIApplication sharedApplication] delegate] setFirstResponder:yourResponderObject];    

And whenever you resign the first responder

[(yourAppDelegate *)[[UIApplication sharedApplication] delegate] unsetFirstResponder];  

Hope this helps someone! :)

Mike A