2009-11-10 5 views
0

오른쪽으로 스크롤되지 않는 스크롤 뷰가 있는데 아래 코드를 단순화했습니다. 실제 코드에서 더 많은 내용을 추가하는보기 및 일부 가로 단추를 그립니다. 버튼 사이에 공백을 드래그하면보기가 스크롤됩니다. 버튼에 손가락을 대면 스크롤되지 않습니다. 관련 제안을 한 후에 delaysContentTouches = YES 줄을 추가하려고 시도했지만 차이가 나는 것 같지 않습니다. UIScrollview with UIButtons - how to recreate springboard?UIScrollView는 자식 뷰가 히트되지 않은 경우에만 작동합니다.

내가 뭘 잘못하고 있니? TIA, 롭

코드

- (void)viewDidLoad { 
    l = [self landscapeView]; 
    [self.view addSubview:l]; 
    [l release];  
} 

- (UIScrollView *) landscapeView { 
    // LANDSCAPE VIEW 
    UIScrollView *landscapeView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 325)]; 
    landscapeView.backgroundColor = [UIColor whiteColor]; 
    landscapeView.delaysContentTouches = YES; 
    NSInteger iMargin, runningY, n; 
    iMargin = 3; 
    runningY = iMargin; 

    for (n = 1; n <= 38; n++) { 
     //add day labels 
     UIButton *templabel = [[UIButton alloc] initWithFrame:CGRectMake(iMargin,runningY,320 - (2 * iMargin),20)]; 
     templabel.backgroundColor = [UIColor grayColor]; 
     [landscapeView addSubview:templabel]; 
     [templabel release]; 
     runningY = runningY + 30; 
    } 
    landscapeView.contentSize = CGSizeMake(320, runningY); 

    return landscapeView; 
} 
에게 업데이트

답변

0

나는 결과를 복제 할 수 없습니다; scrollView를 만들고 버튼을 추가하면 버튼을 터치 다운 할 때 스크롤이 계속 활성화됩니다. 다른 UIScrollView 속성을 설정하거나 단순화 된 코드에 나타나지 않는 메서드를 서브 클래 싱하고 있습니까?

+0

생각하지 마십시오 그래서 코드를 업데이트했습니다. – dny238

0

landScapeView의 getter가 복잡한 생성자이기 때문에 ... [self landscapeView] 또는 self.landscapeView를 수행 할 때마다 완전히 새로운 UIScrollView를 만들고 조작하고있는 것입니다. 그.

나는 당신의 .H 파일에 이런 식으로 뭔가를 시도 할 것 :

@interface MyClass: MyParent { 
    UIScrollView *landscapeView; 
} 

@property (retain) UIScrollView *landscapeView; 

...이 당신의하는 .m 파일 :

@implementation MyClass 

@synthesize landscapeView; 

(void)viewDidLoad 
{ l = [[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 325)] autorelease]; 
    [self.view addSubview:self.landscapeView]; [l release]; 
    landscapeView.backgroundColor = [UIColor whiteColor]; 
    landscapeView.delaysContentTouches = YES; 
    NSInteger iMargin, runningY, n; 
    iMargin = 3; 
    runningY = iMargin; 
    for (n = 1; n <= 38; n++) { //add day labels 
     UIButton *templabel = [[UIButton alloc] initWithFrame:CGRectMake(iMargin,runningY,320 - (2 * iMargin),20)]; 
     templabel.backgroundColor = [UIColor grayColor]; 
     [landscapeView addSubview:templabel]; 
     [templabel release]; runningY = runningY + 30; 
    } 
    landscapeView.contentSize = CGSizeMake(320, runningY); 

}

+0

그렉에 감사드립니다. 나는 그것을 시도 할 것입니다. 내가 생각하기에 그것은 잘못 작성된 오래된 코드에 동의한다. 이것이 스크롤링 문제를 해결할 것이라고 생각하십니까? Rob – dny238

+0

좋아, 변경했습니다. 클릭 할 수없는 버튼에 대해서는 여전히 문제가 있습니다. 문제의 미니 응용 프로그램을 만들어 업로드해야합니까? 나는 잃어 버렸다. – dny238