Iphone iOS滚动视图检测滚动

Iphone iOS滚动视图检测滚动,iphone,ios,ipad,uiscrollview,Iphone,Ios,Ipad,Uiscrollview,我已经阅读了之前所有关于这个主题的帖子,但我仍然无法检测到用户何时在这个iPad应用程序上滚动 My.h: #import <UIKit/UIKit.h> @interface MyApp_ViewController : UIViewController <UIScrollViewDelegate> { } @property (weak, nonatomic) IBOutlet UIButton *otherButton; @property (weak, non

我已经阅读了之前所有关于这个主题的帖子,但我仍然无法检测到用户何时在这个iPad应用程序上滚动

My.h:

#import <UIKit/UIKit.h>

@interface MyApp_ViewController : UIViewController <UIScrollViewDelegate>
{

}
@property (weak, nonatomic) IBOutlet UIButton *otherButton;
@property (weak, nonatomic) IBOutlet UIScrollView *otherScrollView;
@property (weak, nonatomic) IBOutlet UITextView *txtViewHTML;

-(void)k_RootViewPrint:(NSString *) data;

-(void)ActionEventForButton: (id) sender;

@end

但它们都不起作用?我相信这很简单,但我已经做了我能想到的一切,仍然一事无成。任何正确方向的指导都将不胜感激

是否将UIScrollView上的委托设置为ViewController?

是否将UIScrollView上的委托设置为ViewController?

检查是否已设置委托,然后重试

尝试实施`

- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event 
{   
    // If not dragging, send event to next responder
    if (!self.dragging) 
        [self.nextResponder touchesEnded: touches withEvent:event]; 
    else
        [super touchesEnded: touches withEvent: event];
}
`

检查是否已设置委托,然后重试

尝试实施`

- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event 
{   
    // If not dragging, send event to next responder
    if (!self.dragging) 
        [self.nextResponder touchesEnded: touches withEvent:event]; 
    else
        [super touchesEnded: touches withEvent: event];
}
`

如果未登录到
scrollViewDidScroll:
,则滚动视图的委托未设置为视图控制器

您可以在调试器中检查这一点。应用程序启动后,暂停调试器并运行以下命令:

po [[(id)UIApp keyWindow] recursiveDescription]
查看输出以查找UIScrollView的地址。将有一行内容类似于
。获取地址(
0xc894d60
,在我的示例中)并在此调试器命令中使用它:

po [0xc894d60 delegate]

如果它打印类似于
的内容,则您的委托设置正确。如果它打印“无法打印NIL对象的描述”,则表示您尚未设置滚动视图的委托。如果它打印其他内容,则表示您设置了滚动视图的委托不正确。

如果它未登录
scrollViewDidScroll:
,则滚动视图的委托未设置为视图控制器

您可以在调试器中检查这一点。应用程序启动后,暂停调试器并运行以下命令:

po [[(id)UIApp keyWindow] recursiveDescription]
查看输出以查找UIScrollView的地址。将有一行内容类似于
。获取地址(
0xc894d60
,在我的示例中)并在此调试器命令中使用它:

po [0xc894d60 delegate]

如果它打印类似于
的内容,则您的委托设置正确。如果它打印“无法打印NIL对象的描述”,则表示您尚未设置滚动视图的委托。如果它打印了其他内容,则表明您错误地设置了滚动视图的委托。

对于其他可能像我一样丢失的人,以下是代码中的解决方案:

- (void)viewDidLoad
{
[super viewDidLoad];
self.otherScrollView.delegate = self; // This is the KEY

对于其他可能像我一样迷路的人,以下是代码中的解决方案:

- (void)viewDidLoad
{
[super viewDidLoad];
self.otherScrollView.delegate = self; // This is the KEY

您必须将otherScrollView的委托设置为您的文件所有者您必须将otherScrollView的委托设置为您的文件所有者OK,只需设置委托即可。非常感谢。我知道这将是simpleOk,所需要的只是设置委托。非常感谢。我知道这很简单,这是代码中的解决方案(对于像我一样可能丢失的其他人):-(void)viewDidLoad{[super viewDidLoad];self.otherScrollView.delegate=self;//这是关键代码中的解决方案(对于像我一样丢失的其他人):-(void)viewDidLoad{[super viewDidLoad];self.otherScrollView.delegate=self;//这是键