开发者

Get cell's textLabel.text from a cell in UISearchDisplayController?

When I'm getting the cell's textLabel.text in a regular tableView (in the didSelectRowAtIndexPath method) I do (and it works!):

UITableViewCell *cell = (UITableViewCell *)[(UITableView *)self.view cellForRowAtIndexPath:indexPath];
NSLog(@"Cell's text: %@",cell.textLabel.text);
开发者_Python百科

this doesn't work when I click a cell in my UISearchDisplayController. When I push a next view controller in that method, it will push. But I'm always getting "null" for the cell.textLabel.text.

What am I doing wrong?

Thanks a lot in advance!!!


With the help of the guys from iphonedevsdk.com I figured out that this code works:

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSLog(@"Cell's text: %@",cell.textLabel.text);

This is because what the previous code does, is that it is accessing the tableView from the view controller, not the UISearchDisplayController's tableView. This code can access both tableViews.

:-)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜