             let searchTagId = "search"
             let style = HighlightStyle.classForStyle(2)  //青色
             let tag = "<search id=\"\(searchTagId)\" class=\"\(style)\">\(search!.text!)</search>"
-            
+        
             if adjustedRange.location != NSNotFound {
                 bodyHtmls = bodyHtmls.stringByReplacingCharactersInRange(adjustedRange, withString: tag)
                 let resource = book.spine.spineReferences[thePage].resource
-                FolioReader.sharedInstance.readerCenter.currentPage.webView.tag = 1  //didfinishLoad時に行移動させるため
+                FolioReader.sharedInstance.readerCenter.currentPage.webView.tag = 1  //didfinishLoad時に行移動させる為
                 FolioReader.sharedInstance.readerCenter.currentPage.webView.alpha = 0
                 
-                
-                
-                if(FolioReader.sharedInstance.readerCenter.currentPage != thePage + 1){
+                if(FolioReader.sharedInstance.readerCenter.currentPage.pageNumber != thePage + 1){
                     FolioReader.sharedInstance.readerCenter.changePageWith(page: thePage + 1, animated: false, completion: { () -> Void in
-                        var html = FolioReader.sharedInstance.readerCenter.currentPage.getHTML()
-                        html! = html!.stringByReplacingOccurrencesOfString("<body>(.|[\n])*</body>", withString: bodyHtmls as String, options: .RegularExpressionSearch, range: nil)
-                        print("body入れ替え後のhtmlは\(html)")
-                        //それ読み込む(これはuiwebviewのメソッド使用)
-                        FolioReader.sharedInstance.readerCenter.currentPage.webView.loadHTMLString(html! as String, baseURL: NSURL(fileURLWithPath: (resource.fullHref as NSString).stringByDeletingLastPathComponent))
+                        let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(0.3 * Double(NSEC_PER_SEC)))
+                        dispatch_after(delayTime, dispatch_get_main_queue()) {
+                            var html = FolioReader.sharedInstance.readerCenter.currentPage.getHTML()
+                            html! = html!.stringByReplacingOccurrencesOfString("<body>(.|[\n])*</body>", withString: bodyHtmls as String, options: .RegularExpressionSearch, range: nil)
+                            print("body入れ替え後のhtmlは\(html)")
+                            //それ読み込む(これはuiwebviewのメソッド使用)
+                            //バグ修正:移動後にテキストハイライトが消えるのを直す
+                            FolioReader.sharedInstance.readerCenter.currentPage.webView.loadHTMLString(html! as String, baseURL: NSURL(fileURLWithPath: (resource.fullHref as NSString).stringByDeletingLastPathComponent))
+                        }
                     })
-                }else{  //その章内なら
+                }else{
+                    print("その章内なら")
                     var html = FolioReader.sharedInstance.readerCenter.currentPage.getHTML()
                     html! = html!.stringByReplacingOccurrencesOfString("<body>(.|[\n])*</body>", withString: bodyHtmls as String, options: .RegularExpressionSearch, range: nil)
-                    
                     FolioReader.sharedInstance.readerCenter.currentPage.webView.loadHTMLString(html! as String, baseURL: NSURL(fileURLWithPath: (resource.fullHref as NSString).stringByDeletingLastPathComponent))
                 }
             } else {

    func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int) {
        if(alertView.tag == 1){
            if (buttonIndex == 0) {
                self.searchInThisBook()
            } else {
                self.searchInThisChapter()

            }else{
                self.showSearchAlert()
            }
        }else{
            self.showSearchAlert()
        }
    }
    
    func scrollViewDidScroll(scrollView: UIScrollView) {
        //キーボードを隠す
        self.search?.resignFirstResponder()
        //searchInThisBookの場合
        if(self.tempPage != nil){
            let actualPosition = scrollView.contentOffset.y;
            let contentHeight = scrollView.contentSize.height - (450);  // - (someArbitraryNumber)
            print("actualPosition \(actualPosition)")
            print("contentHeight \(contentHeight)")
            if (actualPosition >= contentHeight) {
                if(self.tempPage! < FolioReader.sharedInstance.readerCenter.totalPages){
                    self.tempPage!++  //次の章を検索させる為
                    self.searchInThisBook()
                    //[self.newsFeedData_ addObjectsFromArray:self.newsFeedData_];
                    //self.table!.reloadData()
                }
            }
        }
    }
    
