0

我的项目有问题。我有一个带有子视图的表格视图。我也有一个搜索栏,因为我有一个很大的数组。我知道对于 didSelectRowAtIndexPath, if(indexpath.row==0){... 但是当我在搜索栏中查找一个单词时,当您选择它时,它会将您发送到子视图数组的第一个单词,因为它设置到第一个单元格。我怎样才能让子视图链接到某个单词而不仅仅是行的整数,这样如果单元格单词是“Apple”,那么它会将我发送到 Apple Subview。

PS我正在使用segues开发Xcode 4.2,这对我的项目产生了影响。

4

1 回答 1

0

The problem is in your approach. I think it would be more convenient to put NSArray (or NSMutableArray) data in cells in your data delegate class. So when you find needed cell you can just load details view with a parameter of this NSArray object class instance. For example you use instances of NSManagedObject class in NSArray. (This is very common case because of usage of CoreData framework). So you should edit init method in your target view for receiving this class instance object and working with it. This is the main pattern of object-oriented programming. Or maybe there is some misunderstanding between us, what did you mean when you noticed "subview"? If you need to scroll table to calculated position depended on search bar input, why you don't like the most easy approach with indexPath?

于 2012-03-06T12:40:33.310 回答