iOS 应用在滑动 Web 视图时崩溃



在我的应用程序中,我转到一个主题演讲文件的网页。 用户可以浏览该主题演讲并在自己的设备上进行操作。 我允许所有旋转,并且旋转正常。 为了在横向时腾出更多空间,我让它在滑动时隐藏导航栏。 当我在肖像中执行此操作时,它会隐藏它,一切都很好。 当我在风景中这样做时,我会崩溃。 我在控制台中得到的只是Message from debugger: Terminated due to memory issue. 代码为:

- (void) viewDidAppear:(BOOL)animated {
    self.navigationController.hidesBarsOnSwipe = YES;
}
- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
    [super viewDidUnload];
}
-(void)viewWillAppear:(BOOL)animated {
    [super viewDidLoad];
    self.title = @"Worship Slides";
    [worship loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.316apps.com/Fritch/worship.key"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]];
}

您不应该从 viewWillAppear 处理程序调用 [super viewDidLoad]。这可能会导致您的问题,因为 viewDidLoad 是一次性初始化的东西。

我猜这是你在某处找到的旧代码。并不是说这将解决您的问题,但是...

- (void) viewDidAppear:(BOOL)animated {
    [super viewDidAppear: animated];  // Add super call
    self.navigationController.hidesBarsOnSwipe = YES;
}
// No need for this method if you're not actually overriding it
//- (void)didReceiveMemoryWarning {
//    // Releases the view if it doesn't have a superview.
//    [super didReceiveMemoryWarning];
//
//}
// viewDidUnload was deprecated in iOS 6
//- (void)viewDidUnload {
//    [super viewDidUnload];
//
//}
-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated]; // User correct super call here
    self.title = @"Worship Slides";
    [worship loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.316apps.com/Fritch/worship.key"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]];
}

相关内容

  • 没有找到相关文章

最新更新