我在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
}
更新:我記錄了手勢,結果不知怎麼長按手勢設置爲單元格。
您的TableCell包含任何附件視圖(如複選框,詳細披露按鈕等),其中OS出現此問題。在我的一個項目中,我在IOS7.0中面臨同樣的問題,我在UItableviewcell中使用了附件視圖。爲了解決這個問題,我刪除了這個視圖。 – 2015-02-24 12:35:33
不,它是一個普通的桌面視圖。單元格中只有imageview。 – NSNoob 2015-02-24 12:45:49