2012-03-20 35 views
0

我有一個UISwipeGestureRecognizer的問題,找不到解決方案。UISwipeGestureRecognizer的視圖的一半

我只想在視圖的一半上使用UISwipeGestureRecognizer。但我也想在我的視圖上使用按鈕。

這是我做的。

我有一個UIView名爲firstView它是768 x 1024像素與按鈕。

現在,我想在一個名爲secondViewfirstView頂部是768×512像素添加UIViewUIImageView

刷卡將工作,但我的按鈕secondView(按鈕在firstView)將無法正常工作。

我錯過了什麼功能讓這兩個視圖響應?
還是有比我上面描述的更好的方法嗎?

我刷卡代碼:

UIImageView *secondView = [[[UIImageView alloc] initWithFrame: 
           CGRectMake(0,0,768,512)] autorelease]; 
//UIView *secondView = [[[UIView alloc] initWithFrame:CGRectMake(0,0,768,512)] autorelease]; 

secondView.userInteractionEnabled = YES;  

[firstView addSubview:secondView]; 

oneFingerSwipeLeft = [[[UISwipeGestureRecognizer alloc] initWithTarget:self 
         action:@selector(swipeRecognition:)] autorelease]; 
[oneFingerSwipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft]; 
[secondView addGestureRecognizer:oneFingerSwipeLeft]; 

回答

0

我找到了解決辦法爲自己。我把屏幕放在4個視圖中。現在我可以給每個視圖自己的手勢識別。

// set CGRect for downLeftView 
    downLeftView = [[[UIImageView alloc] initWithFrame:CGRectMake(0,512,384,512)] autorelease]; 

    // set CGRect for downRightView 
    downRightView = [[[UIImageView alloc] initWithFrame:CGRectMake(384,512,384,512)] autorelease]; 

    // set CGRect for upRightView 
    upRightView = [[[UIImageView alloc] initWithFrame:CGRectMake(0,0,384,512)] autorelease]; 

    // set CGRect for upLeftView 
    upLeftView = [[[UIImageView alloc] initWithFrame:CGRectMake(384,0,384,512)] autorelease]; 
相關問題