wxc-navtab导致wxc-navpage留白问题
wxc-navtab每个tab是wxc-navpage(先交页面A),点击wxc-navpage会调整到其他的wxc-navpage(先交页面B),然后在页面B返回到页面A的话会出现留白。效果如下
如果是页面A不是嵌套在wxc-navtab中的话,返回是是没有留白问题。
现在通过在ios代码中加入了,留白问题就解决了。 self.edgesForExtendedLayout = UIRectEdgeNone;
本人不是IOS开发,具体细节不清楚了。。
有没有相关使用的源码,贴上来看一下,这个留白可能是iOS代码布局时对页面起始位置计算有误。UIRectEdgeNone值设置后,tableview或scrollview就不延伸到 navigationBar 下面, 会自动校正位置。这个属性在解决一些布局bug时会比较好用,支持iO7及以后的系统。
// // ViewController.m // xiancheng-english // // Created by walker on 2016/10/27. // Copyright © 2016年 walker. All rights reserved. //
#import "ViewController.h" #import <WeexSDK/WXSDKInstance.h> #import <WeexSDK/WXSDKManager.h> #import <WeexSDK/WXUtility.h>
@interface ViewController () @property (nonatomic, strong) WXSDKInstance *instance; @property (nonatomic, strong) UIView *weexView; @end
@interface ViewController ()
@end
@implementation ViewController
-
(instancetype)init { if (self = [super init]) { }
return self; }
-(void)viewDidLoad { [super viewDidLoad]; self.navigationController.navigationBarHidden = YES; //self.extendedLayoutIncludesOpaqueBars = NO; self.edgesForExtendedLayout = UIRectEdgeNone; self.view.backgroundColor=[UIColor whiteColor]; [self render]; }
-
(void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
-
(void)dealloc { [_instance destroyInstance]; }
-
(void)render { _instance = [[WXSDKInstance alloc] init]; _instance.viewController = self; _instance.frame=self.view.frame; __weak typeof(self) weakSelf = self; _instance.onCreate = ^(UIView *view) { [weakSelf.weexView removeFromSuperview]; weakSelf.weexView = view; [weakSelf.view addSubview:weakSelf.weexView]; }; _instance.onFailed = ^(NSError *error) { NSLog(@"加载错误"); };
_instance.renderFinish = ^ (UIView *view) { NSLog(@"加载完成"); [weakSelf updateInstanceState:WeexInstanceAppear]; }; _instance.updateFinish = ^(UIView *view) { NSLog(@"%@", @"Update Finish..."); };
if (!_url) { return; } NSURL *URL = self.url; NSString *randomURL = [NSString stringWithFormat:@"%@%@random=%d",URL.absoluteString,URL.query?@"&":@"?",arc4random()]; [_instance renderWithURL:[NSURL URLWithString:randomURL] options:@{@"bundleUrl":URL.absoluteString} data:nil]; }
-
(void)updateInstanceState:(WXState)state { if (_instance && _instance.state != state) { _instance.state = state;
if (state == WeexInstanceAppear) { [[WXSDKManager bridgeMgr] fireEvent:_instance.instanceId ref:WX_SDK_ROOT_REF type:@"viewappear" params:nil domChanges:nil]; } else if (state == WeexInstanceDisappear) { [[WXSDKManager bridgeMgr] fireEvent:_instance.instanceId ref:WX_SDK_ROOT_REF type:@"viewdisappear" params:nil domChanges:nil]; }} }
@end
这份源码里没有布局相关的代码,看不出问题来。