私はいくつかの助けが必要です。今日は、セルにUIImageView
が含まれているテーブルビューのカスタムセルについて作業しています。 ImageViewでは、長いジェスチャーを実装したいと思います。私はこれを下に与えるためのコードを実装します。しかし、私は自分のコードで何か間違っている。このビューでは長いプレスで一度サイズが変更されますが、私は数秒後に削除することができますし、テーブルビューのセルに戻ってくる 誰でも私を提案できますか?テーブルビューのカスタムセルの画像上で長押しのジェスチャー
更新:
ここでは、コードです!
- (void)celllongpressed:(UILongPressGestureRecognizer *)gesture
{
if (gesture.state == UIGestureRecognizerStateBegan)
{
cell = (ActivityFeedCell *)[gesture view];
}
if (gesture.state == UIGestureRecognizerStateChanged)
{
cell = (ActivityFeedCell *)[gesture view];
logGes_view=[[UIView alloc]initWithFrame:CGRectMake(5, 0,self.view.frame.size.width-10,self.view.frame.size.height)];
image=[[UIImageView alloc]initWithFrame:CGRectMake(0, 80,self.view.frame.size.width, self.view.frame.size.height-80)];
image.image=cell.updated_imgView.image;
UILabel *name_label=[[UILabel alloc]initWithFrame:CGRectMake(10, 15, 150, 30)];
//city_label.backgroundColor=[UIColor yellowColor];
name_label.text=lgGesNamelbl;
UILabel *city_label=[[UILabel alloc]initWithFrame:CGRectMake(10, 50, 180, 30)];
//city_label.backgroundColor=[UIColor yellowColor];
city_label.text=lgGesCitylbl;
[logGes_view addSubview:city_label];
[logGes_view addSubview:name_label];
[logGes_view addSubview:image];
logGes_view.backgroundColor=[UIColor whiteColor];
[self.view addSubview:logGes_view];
}
if (gesture.state == UIGestureRecognizerStateEnded)
{
// cell = (ActivityFeedCell *)[gesture view];
[logGes_view removeFromSuperview];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UILongPressGestureRecognizer *gesture1 = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(celllongpressed:)];
[gesture1 setDelegate:self];
[gesture1 setMinimumPressDuration:1.0];
[ cell setUserInteractionEnabled:YES];
[cell addGestureRecognizer:gesture1];
}
同じ結果の出力とコードを表示します。 –
clipSubviewsはCustomCellで確認できます!プロトタイプセルを使用している場合は、cellForRowAtIndexPath()またはInterface Builderで無効にしてください。 – Ariel
アタッチ画像plz –