Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.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中检测滚动视图中的按钮触摸_Ios_Uitableview_Uiscrollview_Uibutton - Fatal编程技术网

在ios中检测滚动视图中的按钮触摸

在ios中检测滚动视图中的按钮触摸,ios,uitableview,uiscrollview,uibutton,Ios,Uitableview,Uiscrollview,Uibutton,我有一个带有自定义单元格的表格视图。单元格内有一个水平滚动的滚动视图。在表格视图单元格上添加了一个按钮。但该按钮没有触摸响应。按钮没有添加到滚动视图上。在该按钮上单击,我的任务是更改滚动视图的偏移量,就像下一个按钮一样。如何检测触摸?这是我向滚动视图添加内容的代码 for(int i=0;i<[exerciseArrayForeachSection count];i++){ Exercise *data = [exerciseArrayForeachSection ob

我有一个带有自定义单元格的表格视图。单元格内有一个水平滚动的滚动视图。在表格视图单元格上添加了一个按钮。但该按钮没有触摸响应。按钮没有添加到滚动视图上。在该按钮上单击,我的任务是更改滚动视图的偏移量,就像下一个按钮一样。如何检测触摸?这是我向滚动视图添加内容的代码

 for(int i=0;i<[exerciseArrayForeachSection count];i++){

        Exercise *data = [exerciseArrayForeachSection objectAtIndex:i];

        [_customCell.exTitleLabel setText:data.exName];
         if([data.exImage length] < 1){
             [[AsyncImageLoader sharedLoader] cancelLoadingURL:_customCell.exThumbImageView.imageURL];
         }
      else  if ([data.exImage length] > 0)
        {
            int intExerId = [data.exImage intValue];
            NSString *fullPathString = [NSString stringWithFormat:@"%@%d/%@",EXER_URL,intExerId,data.exImage];
            NSURL* aURL = [NSURL URLWithString:fullPathString];


            _customCell.exThumbImageView.imageURL = aURL;
            imageUrlDetails=fullPathString;
        }

     [_customCell.scroll addSubview:_customCell.excerciseDetailsView];


         _customCell.scroll.contentOffset=CGPointMake(_customCell.scroll.contentOffset.x+320, _customCell.scroll.contentOffset.y);

        }

    [_customCell addSubview:_customCell.scroll];
     [_customCell.scroll bringSubviewToFront:_customCell.nextBtn];


        }
在表视图控制器中

- (void)  nextButtonAction:(id)sender {

    UITableViewCell *cell = (UITableViewCell *)sender;
    _customCell=(CustomCellFor_Dashboard*)cell;


   if ( _customCell.scroll.contentOffset.x <= _customCell.scroll.contentSize.width ) {
       CGRect frame;
       frame.origin.x = _customCell.scroll.contentOffset.x +_customCell.scroll.frame.size.width;
       frame.origin.y = 0;
       frame.size = _customCell.scroll.frame.size;
       [_customCell.scroll scrollRectToVisible:frame animated:YES];
      // pageControlBeingUsed = YES;
   }

}
-(void)下一个按钮操作:(id)发送方{
UITableViewCell*单元格=(UITableViewCell*)发送方;
_customCell=(CustomCellFor_Dashboard*)单元格;

如果(_customCell.scroll.contentOffset.x我认为您需要使用这一行

self.button.userInteractionEnabled = YES;
或者你可以使用

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];

// prevents the scroll view from swallowing up the touch event of child buttons
tapGesture.cancelsTouchesInView = NO;    

[pageScrollView addGestureRecognizer:tapGesture];

我想你需要用这条线

self.button.userInteractionEnabled = YES;
或者你可以使用

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];

// prevents the scroll view from swallowing up the touch event of child buttons
tapGesture.cancelsTouchesInView = NO;    

[pageScrollView addGestureRecognizer:tapGesture];

我想你需要用这条线

self.button.userInteractionEnabled = YES;
或者你可以使用

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];

// prevents the scroll view from swallowing up the touch event of child buttons
tapGesture.cancelsTouchesInView = NO;    

[pageScrollView addGestureRecognizer:tapGesture];

我想你需要用这条线

self.button.userInteractionEnabled = YES;
或者你可以使用

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];

// prevents the scroll view from swallowing up the touch event of child buttons
tapGesture.cancelsTouchesInView = NO;    

[pageScrollView addGestureRecognizer:tapGesture];
试试这个, 在cellForRowAtIndexPath方法中实现此功能:

UIButton *accessoryView = [[UIButton alloc] initWithFrame:CGRectMake(190, 5, 40, 41)];

accessoryView.tag = indexPath.row;
             [accessoryView addTarget: self action:@selector(yourMethodWhichUWantToCall:)forControlEvents:UIControlEventTouchUpInside];
             cell.accessoryView = accessoryView;
然后在该方法中实现以下代码:

UIButton *accessoryView = (UIButton *)sender;

UITableViewCell *cell;

if(isIOS7)
{
   cell = (UITableViewCell *)accessoryView.superview.superview;
}
else
{
   cell = (UITableViewCell *)accessoryView.superview;
}
试试这个, 在cellForRowAtIndexPath方法中实现此功能:

UIButton *accessoryView = [[UIButton alloc] initWithFrame:CGRectMake(190, 5, 40, 41)];

accessoryView.tag = indexPath.row;
             [accessoryView addTarget: self action:@selector(yourMethodWhichUWantToCall:)forControlEvents:UIControlEventTouchUpInside];
             cell.accessoryView = accessoryView;
然后在该方法中实现以下代码:

UIButton *accessoryView = (UIButton *)sender;

UITableViewCell *cell;

if(isIOS7)
{
   cell = (UITableViewCell *)accessoryView.superview.superview;
}
else
{
   cell = (UITableViewCell *)accessoryView.superview;
}
试试这个, 在cellForRowAtIndexPath方法中实现此功能:

UIButton *accessoryView = [[UIButton alloc] initWithFrame:CGRectMake(190, 5, 40, 41)];

accessoryView.tag = indexPath.row;
             [accessoryView addTarget: self action:@selector(yourMethodWhichUWantToCall:)forControlEvents:UIControlEventTouchUpInside];
             cell.accessoryView = accessoryView;
然后在该方法中实现以下代码:

UIButton *accessoryView = (UIButton *)sender;

UITableViewCell *cell;

if(isIOS7)
{
   cell = (UITableViewCell *)accessoryView.superview.superview;
}
else
{
   cell = (UITableViewCell *)accessoryView.superview;
}
试试这个, 在cellForRowAtIndexPath方法中实现此功能:

UIButton *accessoryView = [[UIButton alloc] initWithFrame:CGRectMake(190, 5, 40, 41)];

accessoryView.tag = indexPath.row;
             [accessoryView addTarget: self action:@selector(yourMethodWhichUWantToCall:)forControlEvents:UIControlEventTouchUpInside];
             cell.accessoryView = accessoryView;
然后在该方法中实现以下代码:

UIButton *accessoryView = (UIButton *)sender;

UITableViewCell *cell;

if(isIOS7)
{
   cell = (UITableViewCell *)accessoryView.superview.superview;
}
else
{
   cell = (UITableViewCell *)accessoryView.superview;
}


是否在按钮中添加了目标方法?@keyurbhalodiya已编辑该问题。目标方法正在从tableview单元格类调用,并且该方法已在上面给出[btn addTarget:self action:@selector(NextButtoAction:)forControlEvents:UIControlEventTouchUpInside];问题是nextButtonAction作为委托方法从snother视图中调用。确定然后在从uitableview单元格调用时设置if条件。使用1个bool变量。是否在按钮中添加目标方法?@keyurbhalodiya已编辑该问题。目标方法从tableview单元格类调用,该方法如上所述[btn addTarget:self action:@selector(NextButtoAction:)for ControlEvents:UIControlEventTouchUpInside];问题是nextButtonAction作为委托方法从snother视图中调用。确定然后在从uitableview单元格调用时设置if条件。使用1个bool变量。是否在按钮中添加目标方法?@keyurbhalodiya已编辑该问题。目标方法从tableview单元格类调用,该方法如上所述[btn addTarget:self action:@selector(NextButtoAction:)for ControlEvents:UIControlEventTouchUpInside];问题是nextButtonAction作为委托方法从snother视图中调用。确定然后在从uitableview单元格调用时设置if条件。使用1个bool变量。是否在按钮中添加目标方法?@keyurbhalodiya已编辑该问题。目标方法从tableview单元格类调用,该方法如上所述[btn addTarget:self action:@selector(nextButtonAction:)forControlEvents:UIControlEventTouchUpInside];问题是nextButtonAction作为委托方法从snother视图调用。确定然后在从uitableview单元格调用时设置if条件。使用1个bool变量。但它甚至不调用此方法-(iAction)nextClickActn:(id)发送者;单击但它甚至不调用此方法-(iAction)nextClickActn:(id)发送者;单击但它甚至不调用此方法-(iAction)nextClickActn:(id)发送者;单击但它甚至不调用此方法-(iAction)nextClickActn:(id)sender;在clickbutton上,交互已启用,在添加滚动视图之前,触摸检测到良好。button.clipToBounds=是-尝试此按钮交互已启用,在添加滚动视图之前,触摸检测到良好。button.clipToBounds=是-尝试此按钮交互已启用,在添加t之前滚动视图触摸检测到精细。button.clipToBounds=是-尝试此按钮交互已启用,在添加滚动视图之前,触摸检测到精细。button.clipToBounds=是-尝试此按钮