我有一个UINavigationController
包含一个UIViewController
(比如'FirstVC')。这个 'FirstVC' 包含一个UIScrollView
并且在每个页面上UIScrollView
我都添加了另一个UIViewCotroller
(比如'SecondVC')。这个SecondVC包含一个UIWebView
有几个链接的。我想推另一个UIViewController
(比如'ThirdVC')UIScrollView
。但是当我尝试做同样的事情时,它会使我的应用程序崩溃。这是我应用的代码:
第一风投
- (void)viewDidLoad{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ShowThirdVCNotification:) name:@"ShowThirdVC" object:nil];
}
-(void)showAlbumNotification:(id)notificationObject{
NSLog(@"ShowThirdVCNotification: %@", [notificationObject object]);// It's an array
ThirdVC *controller = [[ThirdVC alloc] initWithNibName:@"ThirdVC" bundle:nil];
[controller setImageArr:[notificationObject object]];
[self.navigationController pushViewController:controller animated:NO];
}
/* SecondVC.view 在加载时被添加到 FirstVC 的 scrollView */
第二VC:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
NSString *urlStr = [NSString stringWithFormat:@"%@", [request URL]];
if ([[urlStr lastPathComponent] rangeOfString:@".jpg"].length) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"ShowAlbum" object:self.imageDetailArr];
return NO;
}
return YES;
}
在线程 1 上,它列出了以下内容:
4 0x00b0a8ab in -[UIWebScrollView didMoveToWindow] ()
5 0x007a583e in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
6 0x007af6d1 in -[UIScrollView _didMoveFromWindow:toWindow:] ()
7 0x007a54bb in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
8 0x007a54bb in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
9 0x007a54bb in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
10 0x007af6d1 in -[UIScrollView _didMoveFromWindow:toWindow:] ()
11 0x007a54bb in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
12 0x007a54bb in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
13 0x007a1c72 in -[UIView(Hierarchy) _postMovedFromSuperview:] ()
14 0x007a04c6 in __UIViewWasRemovedFromSuperview ()
15 0x007a0141 in -[UIView(Hierarchy) removeFromSuperview] ()
16 0x009e69bb in -[UINavigationTransitionView _cleanupTransition] ()
17 0x009e6c86 in -[UINavigationTransitionView _navigationTransitionDidStop] ()
18 0x0079a499 in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] ()
19 0x00799d6d in +[UIViewAnimationState popAnimationState] ()
20 0x007a326c in +[UIView(Animation) commitAnimations] ()
21 0x009e6702 in -[UINavigationTransitionView transition:fromView:toView:] ()
22 0x009e5ccb in -[UINavigationTransitionView transition:toView:] ()
23 0x008422b7 in -[UINavigationController _startTransition:fromViewController:toViewController:] ()
24 0x008423df in -[UINavigationController _startDeferredTransitionIfNeeded] ()
25 0x00842561 in -[UINavigationController __viewWillLayoutSubviews] ()
26 0x0095e4ca in -[UILayoutContainerView layoutSubviews] ()
27 0x007a8301 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()