2015-02-24 14 views
0

我在UIView內有UITableView,我們稱之爲view_A。有一個UIViewController,稱之爲mainViewController。裏面有一個UIButton。點擊該按鈕後,我將view_A作爲子視圖添加到mainViewController的視圖中。桌面視圖中有幾個菜單項。問題是tableview沒有正確響應觸摸。我必須長時間挖掘細胞才能做出選擇。沒有添加任何手勢。沒有其他觀點可以涵蓋它。這絕對是非常棒的,這種行爲。請看下面的代碼並指出可能導致問題的原因。 這是委託執行/演講中mainViewcontroller:爲什麼UITableViewCell需要長時間的手勢?

-(void) showDropDownMenu: (UIButton *) sender 
    { 
     UINib *nib = [UINib nibWithNibName:@"DropDownMenuView" bundle:nil]; 
     self.myView = [[nib instantiateWithOwner:self options:nil] objectAtIndex:0]; 
     self.myView.hidden = NO; 
     self.myView.tag = 101; 
     self.myView.delegate = self; 
     self.myView.btnBack.hidden = YES; 
     CATransition *transition = nil; 
     transition = [CATransition animation]; 
     transition.duration = 0.2; 
     transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 
     transition.type = kCATransitionPush; 
     transition.subtype =kCATransitionFromBottom ; 
     transition.delegate = self; 
     [self.myView.layer addAnimation:transition forKey:nil]; 
     [self.view addSubview:self.myView]; 

    } 

-(void) hideDropDownMenu 
{ 
    CATransition *transition = nil; 
    transition = [CATransition animation]; 
    transition.duration = 0.2;//kAnimationDuration 
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; 
    transition.type = kCATransitionPush; 
    transition.subtype =kCATransitionFromTop; 
    transition.delegate = self; 
    [self.myView.layer addAnimation:transition forKey:nil]; 
    self.myView.tag = 102; 
    [UIView commitAnimations]; 



} 
-(void) navigateBack 
{ 

} 
-(void) themeSelected: (NSIndexPath *) indexPath 
{ 
    NSLog(@"%ld",(long)indexPath.item); 
    themeNumber = [NSString stringWithFormat:@"%li",(indexPath.row+1)]; 
    [self setUpTheme]; 
} 

這是實現cell.h文件:

@interface ThemeTableViewCell : UITableViewCell 
@property (weak, nonatomic) IBOutlet UILabel *themeName; 
@property (weak, nonatomic) IBOutlet UIImageView *themePreview; 

這是實現cell.m文件:

#import "ThemeTableViewCell.h" 
@implementation ThemeTableViewCell 
- (void)awakeFromNib { 
    // Initialization code 
    //ORIGINAL 82 
    self.clipsToBounds = YES; 
} 
- (void)setSelected:(BOOL)selected animated:(BOOL)animated { 
    [super setSelected:selected animated:animated]; 

    // Configure the view for the selected state 
} 
  1. 我的View_A.h文件可以找到here

  2. View_A.m文件可以找到here

更新:我記錄了手勢,結果不知怎麼長按手勢設置爲單元格。

+0

您的TableCell包含任何附件視圖(如複選框,詳細披露按鈕等),其中OS出現此問題。在我的一個項目中,我在IOS7.0中面臨同樣的問題,我在UItableviewcell中使用了附件視圖。爲了解決這個問題,我刪除了這個視圖。 – 2015-02-24 12:35:33

+0

不,它是一個普通的桌面視圖。單元格中只有imageview。 – NSNoob 2015-02-24 12:45:49

回答

0

您禁用電池imageview的用戶交互,如果沒有嘗試這種cell.yourImageView.userInteractionEnabled = NO

+0

我不認爲它會對細胞的表現有任何影響,但無論如何,我嘗試過,問題仍然存在。 – NSNoob 2015-02-24 13:12:32

+1

試試這個來檢查你的手機是否有手勢或是否爲(在cell.contentView.gestureRecognizers中的UIGestureRecognizer *手勢)NSLog(@「%i gesture type%@」,indexPath.row,gesture.class); (@「min%f」,((UILongPressGestureRecognizer *)手勢).minimumPressDuration); NSLog(@「isEnabled%d」,gesture.enabled); }' – 2015-02-24 13:35:31

+0

Blimey。它說長手勢。但是我沒有添加任何手勢,正如你在代碼中看到的那樣。你建議我應該怎麼做? – NSNoob 2015-02-24 14:07:12

相關問題