UPDATE:这似乎是我的自定义单元代码,正在减慢速度,当我使用框架UITableViewCell时,执行segue时没有延迟。
这里是自定义表格视图单元格(它像聊天气泡一样绘制背景):
@implementation SGEMessageCell
@synthesize defaultColor;
@synthesize backgroundView;
@synthesize backgroundRect;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// controls
self.dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 290, 30)];
self.dateLabel.textColor = [UIColor lightGrayColor];
self.dateLabel.font = [UIFont fontWithName:@".HelveticaNeueInterface-Regular" size:10.0f];
self.descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 25, 300, 30)];
self.descriptionLabel.textColor = [UIColor whiteColor];
self.descriptionLabel.font = [UIFont fontWithName:@".HelveticaNeueInterface-Regular" size:14.0f];
backgroundView = [self createBackgroundView:self.defaultColor];
backgroundView.tag = @"backgroundTag";
[self addSubview:backgroundView];
[self addSubview:self.dateLabel];
[self addSubview:self.descriptionLabel];
[self setNeedsDisplay];
}
return self;
}
@end
这是另外两个事件和动作的超类,这是一个事件:
@implementation SGEEventCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self.defaultColor = [UIColor colorWithRed:0.91 green:0.91 blue:0.91 alpha:1];
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
return self;
}
- (UIView *)createBackgroundView:(UIColor *)color
{
CGRect background = CGRectMake(10, 25, self.frame.size.width - 60, 90);
UIView *backgroundView = [[UIView alloc] initWithFrame:background];
backgroundView.backgroundColor = color;
[backgroundView.layer setCornerRadius:7.0f];
[backgroundView.layer setMasksToBounds:YES];
return backgroundView;
}
- (void)updateBackgroundViewColor:(UIColor *)color
{
UIView *bg = [self viewWithTag:@"backgroundTag"];
bg.backgroundColor = color;
}
@end
/ UPDATE
我在主视图控制器(表视图)中具有以下代码
- (void)tableView:(UITableView *)theTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"eventDetailsSegue" sender:self];
}
最初,它确实具有存储所选单元格索引的代码,但是我删除了它,以查看它在执行segue时是否可以解决故障/延迟,但仍会发生。毛刺是,您通常必须在单元格上触摸两次才能使segue第一次执行,然后从此开始,间歇性触摸会导致segue转换延迟。
目标视图控制器使用的是FXForms,但我也删除了它,以尝试解决故障,所以现在它是一个空的视图控制器,带有ui生成器链接的dismiss消息。
@implementation SGEEventDetailsViewController
- (IBAction)dismiss:(id)sender
{
[self.presentingViewController dismissViewControllerAnimated:YES
completion:NULL];
}
@end
谢谢!
为时已晚,但也许我的答案将来会对某些开发人员有所帮助。我在使用Swift 5.1和Xcode 11.1时遇到了相同的错误,该错误在我创建自定义单元并实现didSelectRowAt方法委托时出现,可以修复这个问题:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
DispatchQueue.global(qos: .userInteractive).async {
DispatchQueue.main.async {
self.performSegue(withIdentifier: "mySegueObject", sender: nil)
}
}
}