버튼이있는 셀이 여러 개 있습니다. SimpleTableCell.h
SimpleTableCell.m
에 대해 nav
버튼을 다시 그려 넣은 버튼이있는 SimpleTableCell.xib
에서 생성됩니다. 이 세포들은 다음과 같이 ImagesTableViewController.m
및 ImagesTableViewController.h
에서 호출됩니다 naviguate
는테이블의 셀 식별
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableCell";
SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
NSString *stringy = @"http://www.example.co.uk/";
NSString *link = [stringy stringByAppendingString: images[indexPath.row]];
NSString* encodedString = [link stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
SDImageCache *imageCache = [SDImageCache sharedImageCache];
[imageCache queryDiskCacheForKey:encodedString done:^(UIImage *image, SDImageCacheType cacheType) {
if (image){
cell.thumbnailImageView.image = image;
}else{
[cell.thumbnailImageView setImageWithURL:[NSURL URLWithString:encodedString] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) {
[imageCache storeImage:image forKey:encodedString];
}];
}
}];
[cell.nav addTarget:self action:@selector(naviguate) forControlEvents:UIControlEventTouchUpInside];
}
입니다 : 내가 셀 버튼을 클릭 할 때 indexPath.row
를 연결 걸려
-(void)naviguate{
[UIView animateWithDuration:0.5
delay:0
options: UIViewAnimationOptionCurveEaseOut
animations:^{
[_tableView setFrame:CGRectMake(0, 569, _tableView.frame.size.width, _tableView.frame.size.height)];
}
completion:^(BOOL finished){
[self performSegueWithIdentifier:@"link" sender:self];
}];
}
. 그래서 어느 셀이 눌러 졌는지 알 수 있습니다.
어떻게하면됩니까? 당신이 addTarget
selector
매개 변수를 기대하는 그에게 변경 기억
-(void)naviguate:(id)sender
:
가 어떻게 서브 클래스 않는 태그 귀하의 버튼을 검색하고 사용자가 설정 한 속성으로 인덱스 경로를 추가 할 수 있습니다 셀이 생성 될 때. – maxisme
내 대답을 편집 할 수 없으므로 여기에서해야합니다. UIButton을 하위 클래스로 만들고 인덱스 경로 속성을 추가하는 새 클래스를 만듭니다. SimpleTableCell.xib에서 UIButton을 선택하고 속성 검사기에서 클래스를 UIButton에서 새 클래스로 변경합니다. – Calvedos