我刚刚在我的应用程序中注意到了这个问题,这似乎是一个异常现象,因为我无法确定它是如何/为什么会发生的,而且无法预测何时发生。我有一个自定义UITableViewCell
,我将其加载到我的UITableView
子类中。我的tableView
中始终只有5个单元格,它们是静态的而不是原型。我遇到的问题是,在我解除了我选择其中一个单元格的模态视图后,其他单元格变得越来越多。以下是发生的事情:
•我触摸单元格并按计划执行segue
•触摸细胞后大约10秒多时间执行segue
•我触摸单元格没有任何反应,但如果我触摸视图上的任何其他位置,则会执行segue
这与发布的问题非常相似" Here"同样。
这是我的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//[super tableView:tableView didSelectRowAtIndexPath:indexPath];
//self.selectedObject = [self.objects objectAtIndex:indexPath.row];
NSLog(@"I DID SELECT path %ld", (long)indexPath.row);
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
if(indexPath.row == 0 && self.matchOneSetNum <= 3)
{
self.whereFrom = 1;
[self performSegueWithIdentifier:@"enterScoresSegue" sender:self];
}
if(indexPath.row == 1 && self.matchTwoSetNum <= 3)
{
self.whereFrom = 2;
[self performSegueWithIdentifier:@"enterScoresSegue" sender:self];
}
if(indexPath.row == 2 && self.matchThreeSetNum <= 3)
{
self.whereFrom = 3;
[self performSegueWithIdentifier:@"enterScoresSegue" sender:self];
}
if(indexPath.row == 3 && self.matchFourSetNum <= 3)
{
self.whereFrom = 4;
[self performSegueWithIdentifier:@"enterScoresSegue" sender:self];
}
if(indexPath.row == 4 && self.matchFiveSetNum <= 3)
{
self.whereFrom = 5;
[self performSegueWithIdentifier:@"enterScoresSegue" sender:self];
}
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"enterScoresSegue"])
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
UINavigationController *newView = (UINavigationController *)[segue destinationViewController];
EnterScoresViewController *enter = newView.topViewController;
enter.myDelegate = self;
enter.otherTeam = self.otherTeam;
if(self.whereFrom == 1)
{
enter.match = self.matchOne;
enter.setNumber = self.matchOneSetNum;
enter.matchOnePlayer = self.playerName;
}
if(self.whereFrom == 2)
{
enter.match = self.matchTwo;
enter.setNumber = self.matchTwoSetNum;
enter.matchTwoPlayer = self.playerNameTwo;
}
if(self.whereFrom == 3)
{
enter.match = self.matchThree;
enter.setNumber = self.matchThreeSetNum;
enter.matchThreePlayer = self.playerNameThree;
}
if(self.whereFrom == 4)
{
enter.match = self.matchFour;
enter.setNumber = self.matchFourSetNum;
enter.matchFourPlayers = self.playerStringsFour;
}
if(self.whereFrom == 5)
{
enter.match = self.matchFive;
enter.setNumber = self.matchFiveSetNum;
enter.matchFivePlayers = self.playerStringsFive;
}
}
}
答案 0 :(得分:3)
有一个类似问题的答案为我解决了问题,这里是链接:https://stackoverflow.com/a/23747207/2584268
以下是全文:
填充雷达苹果后回复说:
dispatch_async(dispatch_get_main_queue(), ^{});
到下面的方法的结尾,这就是诀窍:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
在显示控制器的方法中,您可以安排无操作 块会强制runloop旋转,没有延迟。
雷达参考号:15196237,请随意提交另一份并参考此内容。
答案 1 :(得分:0)
[self performSegueWithIdentifier:@“enterScoresSegue”sender:[self.tableView cellForRowAtIndexPath:indexPath]];