UILongPressGestureRecognizer 이벤트에서 셀의 데이터를 가져오고 저장하려고합니다. 내가 시도하고있는 것은 사용자가 길게 누른 다음 길게 누른 다음 대화 상자가 열리면 (거기에 3 개 이상의 버튼이 있음) 사용자가 특정 셀 데이터를 저장하거나 테이블에서 해당 셀을 삭제할 수있는 선택권을 갖게됩니다. 또는 다른 화면으로 이동합니다. 다음은 UILongPressGestureRecognizer에서 테이블 뷰 셀의 데이터 저장
나는이 목적을 위해 코드를 사용하고 있습니다 : 여기-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
UILongPressGestureRecognizer *pressRecongnizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(tableCellPressed:)];
pressRecongnizer.minimumPressDuration = 0.5f;
[cell addGestureRecognizer:pressRecongnizer];
[pressRecongnizer release];
}
if ([tableView isEqual:self.searchDisplayController.searchResultsTableView]){
cell.textLabel.text =
[self.filteredListItems objectAtIndex:indexPath.row];
}
else{
cell.textLabel.text =
[self.groups objectAtIndex:indexPath.row];
}
return cell;}
- (void)tableCellPressed:(UILongPressGestureRecognizer *)recognizer{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add to Favourites", @"Take to Map", @"Delete" ,nil] ;
[alert show];}
내가 내 coreData에 데이터를 저장할 수있는 방법을 알고 싶어요?
@Kevin 낮은 –
고맙습니다하지만, 한 부분의 당신도 즉시 호출하여 테이블 뷰를 새로 고칠 수 있습니다 사용자가 대화 상자에서 삭제 단추를 두드리는 경우 테이블에서 특정 셀을 삭제할 수있는 방법이 내 질문입니다. –
아, 죄송합니다! 알지 못 했어. 편집 됨 =). –