UITableViewCell が応答しなくなります。これは、非常に異なる解決策を伴う非常に異なる問題でした。
UIViewController の subView である私の tableView は、最初は正常に動作し、テーブル内の個々の行を選択できます。ただし、画面の下部に表示される行が選択されたときに独自のポップアップを作成しました (ポップアップは UIView です)。これがポップアップすると、ポップアップの背後の画面を覆う別の UIView も作成し、背景が暗くなります。3 つ目は、ユーザーのタップを追跡するために UITapGestureRecogniser を作成することです。ユーザーが UIView の外側をタップすると、2 つの UIView と TapGestureRecogniser が削除され、deselectRowAtIndex... メソッドが呼び出されます。
ただし、tableView 内で別の文字列を選択してポップアップを再度表示できるようにしたいので、この時点では tableView を使用できません (ポップアップには最終的に、ユーザーが別の場所に移動できるようにするリンクが含まれます)。ビューコントローラー)。
データをリロードし、テーブルビューを削除して置き換え、didSelectRowAtIndex を編集し、deselectRowAtIndex メソッドを削除しようとしましたが、試したことは何も機能していないようで、質問が非常に具体的であるように思われるため、stackoverflow で何も見つかりません (ただし、何かありましたら申し訳ありません)。
コードのいくつかの部分を追加しますが、どこに問題があるのか わからないため、正しい部分をコピーしていない可能性があります.
オーバーヘッドの削除は、tapGesture のセレクター メソッドです。
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(_popOverView == nil)
{
_popOverView = [[UIView alloc]initWithFrame:CGRectMake(20, 200, 280, 150)];
_popOverView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"wood.jpeg"]];
}
if(_mask == nil)
{
_mask = [[UIView alloc] initWithFrame:self.view.frame];
[_mask setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.78]];
}
if (_tapDetector == nil)
{
_tapDetector= [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(removeOverHead:)];
}
[self.view addSubview:_mask];
[self.view addSubview:_popOverView];
[self.view addGestureRecognizer:_tapDetector];
}
-(void) removeOverHead:(UITapGestureRecognizer*) sender
{
CGPoint locationOfTap = [_tapDetector locationInView:self.view];
if (locationOfTap.y < (200 + 150) && locationOfTap.y > 200 && locationOfTap.x > 20 && locationOfTap.x < (20 + 280) ) {
NSLog(@"%f,%f",[_tapDetector locationInView:self.view].x,[_tapDetector locationInView:self.view].y);
}
else
{
[_mask removeFromSuperview];
[_popOverView removeFromSuperview];
[_tapDetector removeTarget:self action:@selector(removeOverHead:)];
/*this idea doesn't work :(
[self.tableView removeFromSuperview];
[self.view addSubview:_tableView];*/
}
}
答えがここにあり、非常に簡単であることを本当に願っています。これを読んでくれてありがとう。