【发布时间】:2015-04-14 04:38:21
【问题描述】:
我遇到的奇怪问题真的很令人沮丧。我为我的应用创建了一个侧边菜单栏,我使用此函数插入:
- (void)insertMenunOnView:(UIView*)view atPosition:(CGPoint)position
{
_menuButton.frame = CGRectMake(position.x, position.y, _menuButton.frame.size.width, _menuButton.frame.size.height);
[view addSubview:_menuButton];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissMenu)];
[view addGestureRecognizer:singleTap];
view.userInteractionEnabled = true;
for (UIButton *button in _buttonList)
{
[_backgroundMenuView addSubview:button];
}
_backgroundMenuView.frame = CGRectMake(view.frame.size.width, 0, 150, view.frame.size.height);
_backgroundMenuView.backgroundColor = [UIColor colorWithRed:0.09 green:0.15 blue:0.18 alpha:0.7f];
[view addSubview:_backgroundMenuView];
}
这里是在我的UITableViewControllerviewDidAppear方法中实现的:
override func viewDidAppear(animated: Bool) {
sideBar.insertMenuOnView(self.view, atPosition: CGPointMake(100, 200))
}
如果我这样做,它会使我的TableView 无用。如果我在多个单元格之间来回快速点击,我可以选择单元格。这样做大约十秒钟后,被点击的单元格将启动适当的 segue。
不,我尝试过这个,希望能够通过将函数更改为来解决这个问题
- (void)insertMenunOnView:(UIWindow*)view atPosition:(CGPoint)position
{ //// do stuff
}
你猜怎么着!?现在,我整个应用程序中的每个tableView 的行为都与第一个相同!大约需要三十到四十次点击,直到单元格最终调用didSelectRowAtIndexPath
到底发生了什么?
【问题讨论】:
标签: ios objective-c uitableview swift uiview