我正在使用一个使用scrollViewController的应用程序,因为我需要有一个垂直和水平滚动,所以它加载NIB的嵌套。
这一切都运行正常但是当我将UIPicker添加到我的一个嵌套的笔尖中时它不会滚动,我已经读过这可以通过在UIScrollView中禁用滚动来轻松修复但是我不是100%确定如何从另一堂课。
scrollViewController.h
@interface scrollViewController : UIViewController <UIScrollViewDelegate>{
UIScrollView* scrollView;
UIPageControl* pageControl;
UIScrollView *vScrollView;
UIScrollView *hScrollView;
BOOL pageControlBeingUsed;
}
@property (nonatomic, retain) IBOutlet UIScrollView* scrollView;
@property (nonatomic, retain) IBOutlet UIPageControl* pageControl;
@property (nonatomic, retain) UIScrollView *vScrollView;
@property (nonatomic, retain) UIScrollView *hScrollView;
- (IBAction)changePage;
@end
scrollViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect bounds = self.view.bounds;
// main guy is a horizontal scroller
hScrollView = [[UIScrollView alloc] initWithFrame:bounds];
hScrollView.contentSize = CGSizeMake(bounds.size.width * 2, bounds.size.height);
hScrollView.delegate = self;
[self.view addSubview:hScrollView];
// the horizontal scroller contains a vertical scroller
vScrollView = [[UIScrollView alloc] initWithFrame:bounds];
vScrollView.contentSize = CGSizeMake(bounds.size.width, bounds.size.height * 2);
vScrollView.delegate = self;
[hScrollView addSubview:vScrollView];
2ndView *view2 = [[2ndView alloc] initWithNibName:@"2ndView" bundle:nil];
[vScrollView addSubview:view2.view];
vScrollView.contentOffset = CGPointMake(0, bounds.size.height);
mainView *vc = [[mainView alloc] initWithNibName:@"mainView" bundle:nil];
vc.view.frame = CGRectOffset(bounds, 0, bounds.size.height);
[vScrollView addSubview:vc.view];
// 3rd View
ValidatorView *vc3 = [[ValidatorView alloc] initWithNibName:@"ValidatorView" bundle:nil];
vc3.view.frame = CGRectOffset(bounds, bounds.size.width, 0);
[hScrollView addSubview:vc3.view];
// enable paging in both directions
hScrollView.pagingEnabled = TRUE;
vScrollView.pagingEnabled = TRUE;
hScrollView.showsHorizontalScrollIndicator = FALSE;
vScrollView.showsVerticalScrollIndicator = FALSE;
hScrollView.alwaysBounceHorizontal = FALSE;
vScrollView.alwaysBounceVertical = FALSE;
vScrollView.canCancelContentTouches = NO;
vScrollView.delaysContentTouches = NO;
hScrollView.bounces = FALSE;
vScrollView.bounces = FALSE;
}
在mainView.m中我创建了一个将UIPicker带到视图上的按钮,但是我希望它能够使用属性更新scrollViewController中的vScrollView
vScrollView.scrollEnabled = NO;
对此有任何帮助将不胜感激。
谢谢Aaron
答案 0 :(得分:0)
您可以在应用程序委托类中拥有一个指向scrollViewController的实例变量,然后您可以将该实例变量的scrollEnabled
用于NO