1

지금은 scrollview 및 tableview가있는 앱을 만들고 있습니다. 여기에 같은 코드를 사용했습니다 : http://johansorensen.com/articles/touches-and-uiscrollview-inside-a-uitableview.html 그러나 scrollview와 tableview의 결합 때문에 didSelectrow 함수가 더 이상 작동하지 않습니다.didSelectrow가 scrollview 및 tableview (iOS)와 작동하지 않습니다.

도와 주셔서 감사합니다.

알아두기 : 명확한 답변, 저는 경험 많은 iOS 개발자가 아닙니다.

답변

1

cell을 숨기면 UITableView의 셀을 만질 수 없기 때문에 didSelectRowAtIndexPath 메서드가 작동하지 않습니다. UITableView

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    return 50.0f; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *cellIdentifier = @"ScrollCell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
    if (!cell) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 
     UIScrollView *scroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 25, 320, 25)]; 
     scroller.showsHorizontalScrollIndicator = NO; 

     UILabel *contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320*4, 25)]; 
     contentLabel.backgroundColor = [UIColor clearColor]; 
     contentLabel.textColor = [UIColor whiteColor]; 
     NSMutableString *str = [[NSMutableString alloc] init]; 
     for (NSUInteger i = 0; i < 100; i++) { [str appendFormat:@"%i ", i]; } 
     contentLabel.text = str; 

     [scroller addSubview:contentLabel]; 
     scroller.contentSize = contentLabel.frame.size; 
     [cell addSubview:scroller]; 
    } 


    return cell; 
} 

에 함께 scrollView을 추가 한 다음이 당신을 위해 유용 할 수 있습니다

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
} 

를 사용하기위한

쓰기 다음 코드는 링크를 형성한다.