简体   繁体   English

TableView reloadData旋转滞后

[英]TableView reloadData lags on rotation

In my willAnimateRotationToInterfaceOrientation method, I have the following: 在我的willAnimateRotationToInterfaceOrientation方法中,我具有以下内容:

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
    if (IS_IPHONE_5) {
        _headerImage.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.height, 50);
        NSURLRequest *_request = [NSURLRequest requestWithURL:[NSURL URLWithString:[Shared LogoLandPhoneRet]]];
        [_headerImage setImageWithURLRequest:_request andDefaultImageName:nil andUserData:nil target:self sucessful:nil failed:nil];
    } else {
        _headerImage.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.height, 50);
        NSURLRequest *_request = [NSURLRequest requestWithURL:[NSURL URLWithString:[Shared LogoLandPhone]]];
        [_headerImage setImageWithURLRequest:_request andDefaultImageName:nil andUserData:nil target:self sucessful:nil failed:nil];
    }
} else {
    if (IS_IPHONE_5) {
        _headerImage.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 50);
        NSURLRequest *_request = [NSURLRequest requestWithURL:[NSURL URLWithString:[Shared LogoPortPhoneRet]]];
        [_headerImage setImageWithURLRequest:_request andDefaultImageName:nil andUserData:nil target:self sucessful:nil failed:nil];
    } else {
        _headerImage.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 50);
        NSURLRequest *_request = [NSURLRequest requestWithURL:[NSURL URLWithString:[Shared LogoPortPhone]]];
        [_headerImage setImageWithURLRequest:_request andDefaultImageName:nil andUserData:nil target:self sucessful:nil failed:nil];
    }
}

//    [NSThread detachNewThreadSelector:@selector(doTable) toTarget:self withObject:NULL];
[_feedTable reloadData];
}

However, when I now rotate my device, it lags and takes about 2-3 seconds to actually rotate. 但是,当我现在旋转设备时,它会滞后约2-3秒才能真正旋转。 Any advice on why this might be? 关于这可能是什么的任何建议?

it lags or it freezes the interface? 滞后还是冻结界面? my guess is that the request freezes the interface so you shoud try making the request asynchronous or try making a cache before.. 我的猜测是请求冻结了接口,因此您应该尝试使请求异步或尝试进行缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM