|
点击tableview中的textField为什么没有出发 didSelectRowAtIndexPath事件? 点击textField外面的地方就可以触发,为什么呢? 如何让点击tableview中的textField触发didSelectRowAtIndexPath事件? |
|
|
textField 和tableView是两码事
|
|
40分 |
自定义或者在cell里面addsubview了,并且没有 userInteractionEnabled = NO;对不对?对不对?
|
|
可以在delegate中
// Called before the user changes the selection. Return a new indexPath, or nil, to change the proposed selection. – (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath; – (NSIndexPath *)tableView:(UITableView *)tableView willDeselectRowAtIndexPath:(NSIndexPath *)indexPath 查看?? |
|
|
点击cell中的textfield这两个方法也没有触发 |
|
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//获取第几分区
NSUInteger section = [indexPath section];
//获取行
NSUInteger row=[indexPath row];
static NSString *simpleTableIdentifier=@"SimpleTableIdentifier";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if(cell==nil){
cell=[[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:simpleTableIdentifier] autorelease];
}
UITextField *txtField2=[[UITextField alloc] initWithFrame:CGRectMake(10, 2, 580, 40)];
//NSLog(@"[tableData objectAtIndex:row]:%@",[tableData objectAtIndex:row]);
txtField2.text=[listData objectAtIndex:row];
txtField2.delegate=self;
txtField2.tag=row+10;
//txtField.backgroundColor=[UIColor redColor];
txtField2.font=[UIFont fontWithName:@"Arial" size:28];
//[txtField scrollRectToVisible:CGRectMake(0, txtField.contentSize.height-15, txtField.contentSize.width, 10) animated:YES];
[txtField2 addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
[cell.contentView addSubview:txtField2];
[txtField2 release];
//cell.textLabel.text=[listData objectAtIndex:row];
//cell.textLabel.font=[UIFont boldSystemFontOfSize:15];
return cell;
}
|
|
|
对 |
|
|
要这样??
txtField2.userInteractionEnabled = NO; 回去试试 |
|
|
txtField2.userInteractionEnabled = NO;
这样txtField都不能输入文字了。 已经用另一种方法解决了。 不过点击txtField还是触发不了willSelectRowAtIndexPath |
|
|
哦 这个给疏忽了??
还可以用页面切换、touch事件中触发cell选中 等思路?? 不过,解决就好了,呵呵 |
|
|
view穿透,就是说两层或以上的view都能同时触发touch事件。
我一直奔着这个思路去的 |
|