알림보기에서 스 와이프중인 셀의 행 번호를 표시하고 싶습니다. 내가 가지고있는 문제는 나는 스 와이프되는 행 번호를 가져올 수 없다는 것인데, 항상 "0"을 보여줍니다.셀이 왼쪽으로 스 와이프 될 때 Alertview에 rownumber를 표시합니다. 인터페이스 빌더에 스 와이프 제스처가 추가되었습니다.
인터페이스 작성 도구로 스 와이프 제스처를 추가했습니다.
내 .H 파일
@property (strong, nonatomic) IBOutlet UISwipeGestureRecognizer *gestureSwipeLeft;
@property (nonatomic, retain) NSIndexPath * indexPath;
@property (nonatomic, assign) int test;
내하는 .m 파일
cellForRowAtIndexPath가 호출 될 때마다 덮어 쓰는 _test 위 내 댓글에 언급, 당신 gestureRecognizer 콜백 내에서 이런 식으로 뭔가를 시도으로- (IBAction)handleSwipeLeft:(UISwipeGestureRecognizer *)sender{
UIAlertView *getRow = [[UIAlertView alloc]initWithTitle:@"RowNumberSwiped" message:[NSString stringWithFormat:@"%i", _test] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[getRow show];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
_test = self.indexPath.row;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myBasicCell"];
thingToDoDoc *things = [self.things objectAtIndex:indexPath.row];
UILabel *lblTitle = (UILabel *)[cell viewWithTag:100];
lblTitle.text = things.data.title;
UIImageView *ratingImageView = (UIImageView *)[cell viewWithTag:101];
// _lblTitle.text = things.data.title;
if (things.data.isDone == 2) {
ratingImageView.image = [UIImage imageNamed:@"checkmark.png"];
}
return cell;
}
'cellForRowAtIndexPath'는 tableView에서 한 행당 한 번 호출되며 행이 표시 될 때마다 '_test' 덮어 쓰기가됩니다. –
맞습니다. 잊었 어! 내 문제에 대한 해결책이 있습니까? – Dridia
답변을 추가했습니다. 문제를 해결할 경우 답을 upvote/up으로 표시하는 것을 잊지 마십시오. 의견을 남기지 않으면 –