2011-09-12 9 views
1

現在、scrollViewControllerを使用するアプリケーションで作業しています。縦と横のスクロールが必要なので、NIBをネストします。UIScrollViewコントローラ - ネストされたペン先からscrollviewプロパティを変更しますか?

これはすべてうまくいきましたが、UIPickerをスクロールしないネストされたペン先の1つに追加すると、UIScrollViewのスクロールを無効にすることでこれを簡単に修正できますが、これを行う方法は100%他のクラスから。 mainView.mで

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; 
} 

私はそれがでvScrollViewを更新したいが、ビュー上にUIPickerをもたらしボタンを作成しましたプロパティを持つscrollViewController

vScrollView.scrollEnabled = NO;

これについての助けに感謝します。

おかげでアーロン

答えて

0

あなたのscrollViewControllerを指すアプリケーションデリゲートクラスのインスタンス変数を持つことができ、その後、あなたはNO

+0

にそのインスタンス変数のscrollEnabledを使用することができますあなたはどのように私ができるの例を持っていますかこれを行う?あなたは '@propertyのようなあなたのAppDelegate内のプロパティを持っている場合 – MonkeyBlue

+0

あなたは( を'どこでもこの '[[のUIApplication sharedApplication]デリゲート]などのアプリケーションにアプリケーションデリゲートをreache(アプリケーションのデリゲート変数に設定します)することができます非構造化、保持)UIScrollViewController * yourScrollController; ' scrollViewControllerを作成するたびに、その値をyourScrollControllerに設定します。 それを無効にしたいときは、これをしてください。 (その名前が何であれ) MyAppDelegate *デル= [[のUIApplication sharedApplication]デリゲート];このよう ' ; ' del.yourScrollController.vScrollView.scrollEnabled = NO '。 –

+0

私のアプリケーションデリゲートは、scrollViewControllerをビューとしてロードし、そのプロパティはどこですか?私は現在、どのように動作するかを変更する必要がありますか?私はアプリケーションの代理人からの直接の接続はないと思います。 – MonkeyBlue

関連する問題