Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableViewCell内的UIScrollView-水平滚动_Ios_Uitableview_Uiscrollview_Ios7 - Fatal编程技术网

Ios UITableViewCell内的UIScrollView-水平滚动

Ios UITableViewCell内的UIScrollView-水平滚动,ios,uitableview,uiscrollview,ios7,Ios,Uitableview,Uiscrollview,Ios7,我一直在尝试在自定义UITableViewCell中设置UIScrollView。我已尝试在自定义.xib文件中添加UIScrollView,对其进行子类化,并手动将其作为子视图添加到cellForRowAtIndexPath方法中的UITableViewCell。在所有这些中,我在cellforrowatinexpath中设置了UIScrollView的contentSize。但无论采用何种方式,我都无法使其水平滚动。这里有一些代码给你一个想法 - (UITableViewCell *)tab

我一直在尝试在自定义
UITableViewCell
中设置
UIScrollView
。我已尝试在自定义
.xib
文件中添加
UIScrollView
,对其进行子类化,并手动将其作为子视图添加到
cellForRowAtIndexPath
方法中的
UITableViewCell
。在所有这些中,我在
cellforrowatinexpath
中设置了
UIScrollView
contentSize
。但无论采用何种方式,我都无法使其水平滚动。这里有一些代码给你一个想法

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *CellIdentifier = @"Custom_Cell";
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    CellIdentifier = @"Custom_Cell";
    }

CustomCell *cell = (CustomCell *)[self.fpTable dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {

    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:nil options:nil];
    // cell = [nib objectAtIndex:0];

    for(id currentObject in nib)

    {

        if([currentObject isKindOfClass:[CustomCell class]])

        {
            cell = (CustomCell *)currentObject;

            break;
        }
    }

    cell.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}

[cell.pgCellScroll setContentSize:CGSizeMake(160*3 + (5*4), 160)];

[cell.pgCellScroll setScrollEnabled:YES];

[cell.pgCellScroll setDelaysContentTouches:YES];
[cell.pgCellScroll setCanCancelContentTouches:NO];

}

知道我哪里出错了吗?非常感谢您的帮助。

为表视图和其中的滚动视图分配一个代理,并在这些代理中实现手势识别器:

 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer
 *)otherGestureRecognizer {
     return YES; }

那么,我是否应该同时将tableView和scrollView子类化,然后在这两个类中实现它的委托方法呢?您已经有了tableView的委托。只需在其中实现这个方法。对于scrollView,您可以将委托分配给同一个对象(该对象可能是您的视图控制器)。