Просмотр исходного кода

ERP Mobile 解决order detail web view 加载问题。

Ray Zhang 8 лет назад
Родитель
Сommit
e6621a6b76

+ 5 - 5
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/Ray.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -10,7 +10,7 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/Functions/modelDetail/HomerModelDetailHeaderCell.m"
-            timestampString = "537083437.522747"
+            timestampString = "537088573.1261981"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "381"
@@ -26,7 +26,7 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/Functions/modelDetail/HomerModelDetailHeaderCell.m"
-            timestampString = "537083437.522818"
+            timestampString = "537088573.126267"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "114"
@@ -74,7 +74,7 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/Functions/modelDetail/HomerModelDetailHeaderCell.m"
-            timestampString = "537083437.52294"
+            timestampString = "537088573.126385"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "96"
@@ -90,7 +90,7 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/Functions/modelDetail/HomerModelDetailHeaderCell.m"
-            timestampString = "537083437.52299"
+            timestampString = "537088573.126436"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "149"
@@ -138,7 +138,7 @@
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "common/Functions/category/CategorySearchFilterViewController.m"
-            timestampString = "537083437.523091"
+            timestampString = "537088573.126536"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
             startingLineNumber = "56"

+ 16 - 0
RedAnt ERP Mobile/common/Functions/order/OrderDetailHtmlCell.m

@@ -12,8 +12,24 @@
 
 - (void)awakeFromNib {
     // Initialization code
+    [super awakeFromNib];
+    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil];
 }
+- (void)dealloc
+{
+    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
+    
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
 
+}
+
+// Handle device orientation changes
+- (void)deviceOrientationDidChange: (NSNotification *)notification
+{
+    [self.webview reload];
+}
 - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
     [super setSelected:selected animated:animated];
 

+ 19 - 10
RedAnt ERP Mobile/common/Functions/order/OrderDetailViewController.m

@@ -273,14 +273,14 @@
 
 - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
 //    self.web_info_height = 0;
-    
-    [self.detailTable.indexPathsForVisibleRows enumerateObjectsUsingBlock:^(NSIndexPath * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-       
-        if (obj.section == 0 && obj.section == 0) {
-            [self.detailTable reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
-        }
-        
-    }];
+//    
+//    [self.detailTable.indexPathsForVisibleRows enumerateObjectsUsingBlock:^(NSIndexPath * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+//       
+//        if (obj.section == 0 && obj.section == 0) {
+//            [self.detailTable reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
+//        }
+//        
+//    }];
     
     
 }
@@ -3404,6 +3404,8 @@
         cell  = (UITableViewCell *) webView.superview.superview.superview;
         indexPath = [self.detailTable indexPathForCell:cell];
     }
+    if(indexPath==nil)
+        return;
     float height=   0;
     if(indexPath.section==0)
         height=self.web_info_height;
@@ -3420,7 +3422,7 @@
     
     CGRect frame = webView.frame;
     NSString *fitHeight = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"];
-    
+//
     if(height==[fitHeight floatValue])
         return;
     frame.size.height = [fitHeight floatValue];
@@ -3438,9 +3440,16 @@
     DebugLog(@"webViewDidFinishLoad ^^^^^^^^^^^^^^^^^reloadRowsAtIndexPaths");
     
     
+    dispatch_async(dispatch_get_main_queue(), ^{
+        // UI更新代码
+//         [self.detailTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
+        [self.detailTable reloadData];
+        //[self.editorTable reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
+    });
     
+
     //    [self.table beginUpdates];
-    [self.detailTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
+
     //    [self.table endUpdates];
     
     //        [self.webviewoprationQueue addOperationWithBlock:^{