该应用在navigationController下有2个viewControllers,UINavigationController
- (根视图) - > UIViewController
- (目前模态) - > UIViewController2
。
输入UIViewController2
后,按主页并让应用程序进入后台,然后响应应用程序,它的屏幕将返回UIViewController
。这发生在真实设备上,但不在模拟器上。
我怀疑是缺少记忆,但UIViewController2
中的对象很少。任何其他原因使应用程序这样做?
更新: 当iPhone未与XCode连接时,我发现了问题!!!
我刚刚测试了与Xcode连接的App,当我按下主页按钮进入后台时,App崩溃了!这意味着当我“反应”应用程序时,它实际上会重新启动,它会转到UIViewController。
let localfilePath = NSBundle.mainBundle().URLForResource("home", withExtension: "html");
var webViewRequest:NSURLRequest!
override func viewDidLoad() {
super.viewDidLoad()
webViewRequest = NSURLRequest(URL: localfilePath!);
initSubviews()
}
func initSubviews() {
let fm: CGRect = UIScreen.mainScreen().bounds
self.mainScrollView = UIScrollView(frame:CGRectMake(0, 0, fm.size.width, fm.size.height))
self.mainScrollView!.contentSize = CGSizeMake(self.mainScrollView!.frame.size.width * CGFloat(numPages), self.mainScrollView!.frame.size.height)
self.mainScrollView!.backgroundColor = UIColor.whiteColor()
self.mainScrollView!.pagingEnabled = true
self.mainScrollView!.bounces = false
self.mainScrollView!.showsHorizontalScrollIndicator = false;
self.mainScrollView!.scrollRectToVisible(CGRectMake(mainScrollView!.frame.size.width, 0, mainScrollView!.frame.size.width, mainScrollView!.frame.size.height), animated: false)
self.mainScrollView!.delegate = self
self.view.addSubview(mainScrollView!);
prevWebView = runFunc.setWebView(0)
currWebView = runFunc.setWebView(runFunc.screenWidth)
nextWebView = runFunc.setWebView(runFunc.screenWidth*2)
currWebView.delegate = self
prevWebView.delegate = self
nextWebView.delegate = self
prevWebView.tag = 0
currWebView.tag = 1
nextWebView.tag = 2
prevWebView.backgroundColor = UIColor.whiteColor()
currWebView.backgroundColor = UIColor.whiteColor()
nextWebView.backgroundColor = UIColor.whiteColor()
mainScrollView.addSubview(prevWebView)
mainScrollView.addSubview(currWebView)
mainScrollView.addSubview(nextWebView)
currWebView.scrollView.delegate = self
prevWebView.scrollView.delegate = self
nextWebView.scrollView.delegate = self
prevWebView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal
currWebView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal
nextWebView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal
currWebView.loadRequest(webViewRequest);
NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "loadPrevNext", userInfo: nil, repeats: false)
}
func loadPrevNext() {
let prev = getPrev(currVolume, theChapter: currChapter)
prevVolume = prev["volume"]!
prevChapter = prev["chapter"]!
prevChapterArr = runFunc.getLection(prev["volume"]!, theChapter: prev["chapter"]!)
let next = getNext(currVolume, theChapter: currChapter)
nextVolume = next["volume"]!
nextChapter = next["chapter"]!
nextChapterArr = runFunc.getLection(next["volume"]!, theChapter: next["chapter"]!)
prevWebView.loadRequest(webViewRequest);
nextWebView.loadRequest(webViewRequest);
}