0
想象一下這個場景(下面的一些代碼)後駁回:滯後/延遲上ModalViewController加載廈門國際銀行視圖在SKView
- 我有一個SKView上的ViewController。
- 我在skview上加載了一個xib視圖(外部.xib文件)(xib視圖是一個類似於小菜單視圖,並不包含完整的屏幕)。
- 然後,我顯示視圖控制器模態從SKView的控制器
- 當我關閉此模態視圖控制器,對每第二個解僱(所以,我顯示它模態,駁回,它是好的,那麼我重複滯後,有延遲,然後重複,工作正常,然後再次,有延遲...等等)
- 如果我不使用SKView(如果我只是使用UIView),那延遲不會發生。它只發生在我使用SKView時。
可能是什麼原因造成的?這是產生此問題的簡化代碼:
@implementation NOZTestController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
// button that loads xib view onto the current skview
UIButton *showxib = [[UIButton alloc] initWithFrame:CGRectMake(20, 80, 280, 30)];
[showxib setTitle:@"Add xib view here" forState:UIControlStateNormal];
[showxib addTarget:self action:@selector(showxibTapped) forControlEvents:UIControlEventTouchUpInside];
// button that loads a view controller programmatically
UIButton *showmodal = [[UIButton alloc] initWithFrame:CGRectMake(20, 120, 280, 30)];
[showmodal setTitle:@"Show modal" forState:UIControlStateNormal];
[showmodal addTarget:self action:@selector(showmodalTapped) forControlEvents:UIControlEventTouchUpInside];
self.view = [[SKView alloc] initWithFrame:self.view.frame];
SKView *v = (SKView *)self.view;
//UIView *v = self.view;
[v addSubview:showxib];
[v addSubview:showmodal];
}
- (void)showxibTapped
{
// displays the xib view
[NOZPlayAgainView presentOnView:self.view inRect:CGRectMake(20, 200, 280, 160) withDelegate:self];
}
- (void)showmodalTapped
{
// displays the modal window
UIViewController *vc = [[UIViewController alloc] init];
UIButton *dismiss = [[UIButton alloc] initWithFrame:CGRectMake(40, 40, 240, 40)];
[dismiss setTitle:@"Dismiss" forState:UIControlStateNormal];
[dismiss addTarget:self action:@selector(dismissModal) forControlEvents:UIControlEventTouchUpInside];
[vc.view addSubview:dismiss];
[self presentViewController:vc animated:YES completion:nil];
}
- (void)dismissModal
{
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
}
@end
您是否找到解決方法? – defense2000x