开发者

Alternative for didSelectRowAtIndexPath when UITableViewCells are UIResponders?

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 th开发者_Go百科ere a way to get that method to fire?

Thanks!


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.


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! :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜