开发者

custom tablecell valueForSelectedRow problem

开发者 https://www.devze.com 2022-12-16 09:34 出处:网络
I have created a custom uitablecell which contains several values.When the user selects a row, I want to be able to select that row\'s content for one of the values in the custom uitablecell.If the ce

I have created a custom uitablecell which contains several values. When the user selects a row, I want to be able to select that row's content for one of the values in the custom uitablecell. If the cell looks like this:

ba_type   varchar2(20)    P
source    varchar2(20)    P
row_qual  varhcar2(20)

If the user has sel开发者_StackOverflowected the 'source varchar2(20) P' row, I want to be able to grab the value of 'source' out for my next query.

thx, wes


Strictly speaking, you've created a tableview cell that displays several values. Sitting in memory somewhere behind that is an array that contains the actual data. That's how MVC architecture works.

Ideally, you have some data structure in memory that corresponds to the cells. If you had an NSMutableArray in memory, you could retrieve the value by doing

// assumes one section in the table view
    NSString* sourceForNextQuery = [dataSourceUsedToPopulate objectAtIndex: indexPath.row];  

inside didSelectRowAtIndex

If you insist on retrieving the text from the label in the table view cell, when you create the label that contains it, add a tag (mySourceLabel.tag = 999). Then find that tag again by using searching for the tag, the get the text (UILabel.text)

But really, you want to separate the presentation of the data from the underlying model, and have the controller contain the data.

0

精彩评论

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

关注公众号