불균형 통화의 시작 / 종료 모양 전환
비슷한 오류 가 발생하는 다른 user-에 대해 SO 읽었를 지만이 오류는 다릅니다.
처음에 View Controller를 추가했을 때이 메시지가 나타납니다.
Unbalanced calls to begin/end appearance transitions for
<UITabBarController: 0x197870>
앱의 구조는 다음과 가변적입니다.
5 개의 View Controller에서 사용할 수있는 5 개의 TabBarController가 있습니다. 초기 표시 탭에서 앱의 소개로 기계 장치 할 새 View Controller를 호출합니다.
이 코드를 사용하여 소개 뷰 컨트롤러를 호출합니다.
IntroVC *vc = [[IntroVC alloc] init];
[self presentModalViewController:vc animated:YES];
[vc release];
이 IntroVC
뷰 컨트롤러가 위의 오류가 표시됩니다.
추신 : 저는 iOS 4.3 앱을 개발하면서 xCode 4.2 및 iOS 5.0 SDK를 사용하고 있습니다.
주변 코드를 더 많이 찾을 수없는 추측 대답을 할 수 없습니다.
당신은 사용하지 않을
UIViewController
의 초기화 지정initWithNibName:bundle:
. 그냥 대신 사용init
.또한
self
탭 막대 전용의보기 중 하나 일 수 있습니다. 항상 최상위 컨트롤러에서 뷰 컨트롤러를 표시하십시오.이 경우 탭 막대 컨트롤러에 뷰 컨트롤러 컨트롤러 뷰 컨트롤러를 표시하십시오. 델리게이트를 실제적으로보기 컨트롤러에 많은 비용이들 것입니다.
애니메이션을 YES에서 NO로 변경 하여이 오류를 수정했습니다.
에서 :
[tabBarController presentModalViewController:viewController animated:YES];
에 :
[tabBarController presentModalViewController:viewController animated:NO];
앱 초기화가 완료되기 전에 모달 vc를 표시하여 경고를 생성 할 수 있습니다. 즉, 탭이있는 응용 프로그램 템플릿 앱을 시작하고 self.tabBarController 위에 모달 vc를 응용 프로그램 : didFinishLaunching의 마지막 줄로 표시하십시오. 경고가 나타납니다. 솔루션 : 스택을 먼저 풀고 다른 메소드에 모달 vc를 표시하십시오 (delay : 0.0 with performSelector로 호출 됨).
메소드를 viewWillAppear로 이동하고 한 번만 실행 가능 보호하십시오 (속성을 설정하는 것이 좋습니다).
경우에, 대한 많은 또 다른 해결책은 다음 과 같이 수행하여 부적절한 초기화 절차와 같은 절차가 완료된 후UIViewController
들 간 전환이 발생 하도록하는을 구석으로입니다.
__weak MyViewController *weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf presentViewController:vc animated:YES];
});
이것은 또한 일반적인 것입니다 pushViewController:animated:
.
나는 같은 문제가 있었다. viewDidLoad
내 첫 번째 방법을 내부에서 호출했습니다.UIViewController
- (void)viewDidLoad{
[super viewDidLoad];
[self performSelector:@selector(loadingView)
withObject:nil afterDelay:0.5];
}
- (void)loadingView{
[self performSegueWithIdentifier:@"loadedData" sender:self];
}
두 번째 내부 UIViewController
에서 0.5 초 지연으로 동일하게 수행했습니다. 지연을 더 높은 값으로 변경하면 작동합니다. 다른 segue 나중에 segue를 너무 빨리 수행 할 수 없습니다.
다른 View Controller에서 내 로그인 View Controller를 표시해야 할 때도 동일한 문제가 발생했습니다. 사용자에게 권한이없는 경우 다른 View Controller의 ViewDidLoad 메서드 (권한이없는 경우-> presentModalViewController) 에서이 작업을 수행했습니다. ViewDidAppear 방법에서 시작하면이 문제가 해결되었습니다. ViewDidLoad는 속성 만 초기화 한 다음 실제 표시보기 알고리즘이 시작된다고 생각합니다! 따라서 viewDidAppear 메소드를 사용하여 모달 전환을 수행해야합니다!
나는 같은 문제에 많은 문제가 있습니다. 나는 이것으로 해결했다.
- storyboad instanceiateViewControllerWithIdentifier 메소드를 사용하여 ViewController를 시작합니다. 즉
Intro *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"introVC"];
[self.tabBarController presentModalViewController : vc animated:YES];
스토리 보드에 뷰 컨트롤러가 있는데 어떤 것이 든 사용하는 것이 [[introvc alloc] init];
효과가 없습니다.
나는 글로 해결했다
[self.navigationController presentViewController:viewController
animated:TRUE
completion:NULL];
세 리더 에서이 문제가 발생했습니다. 누군가 사용자 정의 TabBarController 클래스에서 viewWillAppear 및 viewWillDisappear의 내부를 설정하는 것을 잊었습니다.
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// code...
}
or
- (void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
// code...
}
당신이 사용하는 경우 transitioningDelegate
(이 질문의 예에없는 경우)도 설정 에 .modalPresentationStyle
.Custom
빠른
let vc = storyboard.instantiateViewControllerWithIdentifier("...")
vc.transitioningDelegate = self
vc.modalPresentationStyle = .Custom
오타 때문에이 문제가 발생했습니다.
override func viewDidAppear(animated: Bool) {
super.viewWillAppear(animated)
대신에
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
"DidAppear"대신 슈퍼에서 "WillAppear"를 호출했습니다.
나는 같은 오류가 있었다. 3 개의 항목이있는 탭 표시 줄이 있는데 무의식적으로를 사용하여 탭 표시 줄의 항목 2에서 항목 1의 루트 뷰 컨트롤러를 호출하려고했습니다 performSegueWithIdentifier
.
무슨 일이 일어나는지보기 컨트롤러를 호출하고 몇 초 후에 항목 2의 루트보기 컨트롤러로 돌아가서 해당 오류를 기록합니다.
분명히 항목의 루트 뷰 컨트롤러를 다른 항목으로 호출 할 수 없습니다.
그래서 대신 performSegueWithIdentifier
나는 사용했다 [self.parentViewController.tabBarController setSelectedIndex:0];
이것이 누군가를 돕기를 바랍니다.
나는 똑같은 문제가 있었고 다른 누군가가 비슷한 것을 겪을 경우 게시 할 것이라고 생각했습니다.
제 경우에는 UITableViewController에 길게 누르기 제스처 인식기를 연결했습니다.
UILongPressGestureRecognizer *longPressGesture = [[[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(onLongPress:)]
autorelease];
[longPressGesture setMinimumPressDuration:1];
[self.tableView addGestureRecognizer:longPressGesture];
onLongPress 선택기에서 다음보기 컨트롤러를 시작했습니다.
- (IBAction)onLongPress:(id)sender {
SomeViewController* page = [[SomeViewController alloc] initWithNibName:@"SomeViewController" bundle:nil];
[self.navigationController pushViewController:page animated:YES];
[page release];
}
제 경우에는 길게 누름 인식기가 한 번 이상 실행되어 "SomeViewController"가 여러 번 스택에 푸시 되었기 때문에 오류 메시지를 받았습니다.
해결책은 SomeViewController가 스택에 푸시 된시기를 나타내는 부울을 추가하는 것이 었습니다. 내 UITableViewController의 viewWillAppear 메서드가 호출되었을 때 부울을 다시 NO로 설정했습니다.
에서 2 + 스위프트 나 작동을 위해 :
스토리 보드에 UITabBarViewController가 있고 다음과 같이 selectedIndex 속성이 있습니다.
그러나 나는 그것을 삭제하고 다음과 같이 초기 클래스의 viewDidLoad 메서드를 추가합니다.
override func viewDidLoad() {
super.viewDidLoad()
self.tabBarController?.selectedIndex = 2
}
누군가를 도울 수 있기를 바랍니다.
실제로 푸시 애니메이션이 끝날 때까지 기다려야합니다. 따라서 UINavigationController를 위임하고 애니메이션이 끝날 때까지 밀기를 방지 할 수 있습니다.
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
waitNavigation = NO;
}
-(void)showGScreen:(id)gvc{
if (!waitNavigation) {
waitNavigation = YES;
[_nav popToRootViewControllerAnimated:NO];
[_nav pushViewController:gvc animated:YES];
}
}
@danh가 제안했듯이 내 문제 UITabBarController
는 준비 되기 전에 모달 vc를 제공한다는 것 입니다. 그러나 뷰 컨트롤러를 표시하기 전에 고정 지연에 의존하는 것이 불편 함을 느꼈습니다 (테스트에서에서 0.05-0.1s 지연을 사용해야했습니다 performSelector:withDelay:
). 내 솔루션은 UITabBarController
의 viewDidAppear:
메서드 에서 호출되는 블록을 추가하는 것입니다.
PRTabBarController.h :
@interface PRTabBarController : UITabBarController
@property (nonatomic, copy) void (^viewDidAppearBlock)(BOOL animated);
@end
PRTabBarController.m :
#import "PRTabBarController.h"
@implementation PRTabBarController
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (self.viewDidAppearBlock) {
self.viewDidAppearBlock(animated);
}
}
@end
지금에 application:didFinishLaunchingWithOptions:
PRTabBarController *tabBarController = [[PRTabBarController alloc] init];
// UIWindow initialization, etc.
__weak typeof(tabBarController) weakTabBarController = tabBarController;
tabBarController.viewDidAppearBlock = ^(BOOL animated) {
MyViewController *viewController = [MyViewController new];
viewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[weakTabBarController.tabBarController presentViewController:navigationController animated:NO completion:nil];
weakTabBarController.viewDidAppearBlock = nil;
};
스토리 보드를 사용하는 경우 viewDidAppear에 새 뷰 컨트롤러를 표시하는 코드를 넣는 것이 좋습니다. 또한 "분리 된 뷰 컨트롤러에 뷰 컨트롤러를 표시하는 것은 권장되지 않습니다."라는 경고도 제거됩니다.
-(void) beginAppearanceTransition : (BOOL) isAppearing animated : (BOOL) animated 및-(void) endAppearanceTransition이 클래스에서 함께 생성되는지 확인해야합니다.
나는 같은 문제가 있었다. 개발할 때 화면을 우회하고 싶었습니다. 선택기 메서드를 호출하여 viewDidLoad에서 한 뷰 컨트롤러에서 다른 뷰 컨트롤러로 탐색했습니다.
문제는 ViewController가 다른 ViewController로 전환하기 전에 전환을 완료하도록해야한다는 것입니다.
이것은 내 문제를 해결했습니다. ViewController가 다른 것으로 전환하기 전에 전환을 완료하려면 지연이 필요합니다.
self.perform(#selector(YOUR SELECTOR METHOD), with: self, afterDelay: 0.5)
루트 TVC에서 TVC A로 이동 한 다음 TVC B로 이동했을 때이 문제가 발생했습니다. TVC BI에서 "로드"버튼을 탭한 후 바로 루트 TVC로 바로 돌아가고 싶었습니다 (TVC A를 다시 방문 할 필요가 없으므로 왜 그렇게합니까). . 나는 :
//Pop child from the nav controller
[self.navigationController popViewControllerAnimated:YES];
//Pop self to return to root
[self.navigationController popViewControllerAnimated:YES];
... '시작 / 종료 등 불균형 호출'오류가 발생했습니다. 다음은 오류를 수정했지만 애니메이션은 없습니다.
//Pop child from the nav controller
[self.navigationController popViewControllerAnimated:NO];
//Then pop self to return to root
[self.navigationController popViewControllerAnimated:NO];
이것은 내 최종 솔루션이었고 오류가 없었으며 여전히 애니메이션되었습니다.
//Pop child from the nav controller
[self.navigationController popViewControllerAnimated:NO];
//Then pop self to return to root, only works if first pop above is *not* animated
[self.navigationController popViewControllerAnimated:YES];
UIButton을 스토리 보드 segue 작업 (IB에서)에 연결했을 때이 오류가 발생했지만 나중에 IB performSegueWithIdentifier
에서 첫 번째 항목을 제거하는 것을 잊어 버리는 것을 프로그래밍 방식으로 호출하도록 결정했습니다 .
본질적으로 그것은 segue 호출을 두 번 수행 하고이 오류를 주었고 실제로 내 견해를 두 번 밀었습니다. 수정 사항은 segue 호출 중 하나를 제거하는 것입니다.
이것이 나만큼 피곤한 사람에게 도움이되기를 바랍니다!
'IT' 카테고리의 다른 글
PhotoPicker 검색 오류 : 오류 도메인 = PlugInKit 코드 = 13 (0) | 2020.07.26 |
---|---|
중첩 클래스의 범위? (0) | 2020.07.26 |
C ++에서 참조로 전달되는 동안 매개 변수의 라우팅 (0) | 2020.07.26 |
JSFiddle에서 JavaScript가 작동하지 않는 이유는 무엇입니까? (0) | 2020.07.26 |
안드로이드에서 비트 맵의 크기를 조정하는 가장 쉬운 메모리 방법? (0) | 2020.07.26 |