我是一個新的程序員的我的手機通按鈕兩個參數點擊(訪問按鈕點擊兩個字符串)
我有一個小問題....我想傳遞兩個參數按鈕點擊....
//---insert individual row into the table view---
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"Cell %i",indexPath.section]];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:[NSString stringWithFormat:@"Cell %i",indexPath.section]] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;//my code.... change the color or selected cell
search_items *pro = [searchCount objectAtIndex:[indexPath row]];
NSString *string1=[[NSString alloc]init];
NSString *string2=[[NSString alloc]init];
/// i wants access these two strings on buttonClicked Method...(pass as a argument):)
string1=pro.s_showroomName;
string2=pro.s_productName;
UIButton* aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
aButton.frame = CGRectMake(150, 15,150,40);
[aButton setTag:indexPath.row];
[aButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:aButton];
UIImage *img = [UIImage imageNamed:@"image.png"];
[aButton setImage:img forState:UIControlStateNormal];
[aButton setTitle:@"View Details" forState:UIControlStateNormal];
[aButton addSubview:buttonLabel1];
NSString *filepath=[[NSBundle mainBundle]pathForResource:pro.s_image ofType:@"png"];
UIImage *image=[UIImage imageWithContentsOfFile:filepath];
cell.imageView.image=image;
return cell;
}
-(void)buttonClicked:(UIButton*)sender {
//int tag = sender.tag;
}
你是什麼意思傳遞兩個參數?你希望你的單元格包含的信息可以在按鈕回調中訪問嗎? – jbat100
@jbat ...謝謝你給我寶貴的時間........是的..我想要訪問信息包含的單元格...在我的方法buttonClicked ... – GauravBoss