我的應用程序有一個問題:當互聯網連接不好時,在viewWillAppear
結束和viewDidAppear
開始之間有一個延遲(大約4秒)。但是當網絡正常時,問題不會發生!延遲時間viewWillAppear和viewDidAppear當互聯網連接不好
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[_btnMenu setBadgeTextColor:[UIColor whiteColor]];
[self updateNotification];
[_btnMenu setBadgeEdgeInsets:UIEdgeInsetsMake(15, 0, 0, 8)];
[_btnMenu setHideWhenZero:YES];
[self setNeedsStatusBarAppearanceUpdate];
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[WSProgressHUD dismiss];
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[super setUpLocalizationString];
willRoute = NO;
// delay single tap recognition until it is clearly not a double
[_mapBoxView removeGestureRecognizer:taptap];
[_mapBoxView removeGestureRecognizer:doubleTap];
doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:nil];
doubleTap.numberOfTapsRequired = 2;
[self.mapView addGestureRecognizer:doubleTap];
taptap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissCallout:)];
[taptap requireGestureRecognizerToFail:doubleTap];
[taptap requireGestureRecognizerToFail:_longPress];
taptap.delegate = self;
[self.mapBoxView addGestureRecognizer:taptap];
GoongInstance.mapBoxView = _mapBoxView;
self.navigationController.navigationBarHidden = YES;
[self.view layoutIfNeeded];
[self.view updateConstraints];
_searchTextField.delegate = self;
[_searchTextField resignFirstResponder];
if (!isPresentingOtherVC) {
_radialMenuYConstraint.constant = -70;
_dropPinViewHeightConstraint.constant = 0;
_btnWarning.hidden = YES;
[_mapBoxView setScrollEnabled:YES];
[_mapBoxView setZoomEnabled:YES];
[_mapBoxView setRotateEnabled:YES];
[_mapBoxView setPitchEnabled:YES];
[_mapBoxView removeFromSuperview];
[self.mapView addSubview:_mapBoxView];
_mapBoxView.frame = CGRectMake(0, 0, _mapView.frame.size.width, _mapView.frame.size.height);
_mapBoxView.delegate = self;
[self.view layoutIfNeeded];
}
}
你能給我們更多的信息?通常這些回調與互聯網連接無關。也許你正在做一些阻止viewWillAppear主線程的東西? – batu
@ skillerman14:@batu是對的。請分享你的'viewWillAppear'和'viewDidAppear'代碼。然後我們可以說出什麼是錯的。 – Poles
可能運行一些線程阻止互聯網通話。 –