コードに Simple critical Problem が 1 つあります。
Editボタン(ナビゲーションバーにあります)を押したときのTableviewで、 UITableview のメソッドを編集する必要があります。My Cell にあるボタンとラベルを非表示にしたい。
コード :
このようにボタンを追加しています..
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *currentCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
currentCell = nil;
if (currentCell==nil)
{
currentCell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
BtnEmail=[UIButton buttonWithType:UIButtonTypeCustom];
//BtnEmail = (UIButton *)[currentCell viewWithTag: 3];
BtnEmail.frame=CGRectMake(265, 17, 25, 25);
BtnEmail.tag=indexPath.row;
//[BtnEmail setTitle:@"E-mail" forState:UIControlStateNormal];
[BtnEmail setBackgroundImage:[UIImage imageNamed:@"email.png"] forState:UIControlStateNormal];
[BtnEmail addTarget:self action:@selector(BtnEmail:) forControlEvents:UIControlEventTouchUpInside];
[currentCell.contentView addSubview:BtnEmail];
[currentCell.contentView bringSubviewToFront:BtnEmail];
return currentCell;
}
私の編集ボタンは Declare like this
編集ボタン :
self.navigationItem.rightBarButtonItem = self.editButtonItem;
編集をクリックすると、 My this method will call が呼び出されます。
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
[listTableView setEditing:editing animated:animated];
if(editing)
{
self.navigationItem.leftBarButtonItem.enabled = NO;
//BtnEmail.frame=CGRectMake(355, 17, 25, 25);
BtnEmail.hidden = TRUE;
}
else
{
self.navigationItem.leftBarButtonItem.enabled = YES;
//BtnEmail.frame=CGRectMake(265, 17, 25, 25);
BtnEmail.hidden = FALSE;
}
[super setEditing:editing animated:animated];
}
この場合、私の Last セル Button と Lable は、すべてを非表示にするわけではありません。Cell のすべての UIButton を非表示にする必要があります。
テーブルに3つのセルがある場合のように、最後のボタンのみを非表示にします..
ありがとう 。