Skip to content

刷新控件和正文之间有一段空白 #46

@woshi82

Description

@woshi82

问题: 如何可以去掉这段空白?(调试了很久,一直没有找到原因,请大佬指教一下^ ^)
如图:
image
image

代码:

// js
import ScrollView from '../../components/MMScrollView'

export default class Chat extends Component {
  render() {
    return (
      <ScrollView
        style={{ flex: 1, backgroundColor: 'yellow' }}
        refreshControl={<MMRefreshControl />}
        reqRefresh={() => {}}
      >
        <View style={{ height: 800, backgroundColor: 'rgba(0, 0, 0, 0.2)', justifyContent: 'center' }}>
          <Text>我是正文我是正文</Text>
          <Text>我是正文我是正文</Text>
          <Text>我是正文我是正文</Text>
          <Text>我是正文我是正文</Text>
        </View>
      </ScrollView>
    )
  }
}

...
...
const RCTMMRefreshView = requireNativeComponent('RCTMMRefreshView', MMRefreshControl)

export default class MMRefreshControl extends Component {
  render() {
    const { onHeaderPulling, onHeaderReleasing, ...props } = this.props
    const nativeProps = { ...props,
      ...{
        onMMRefresh: this._onRefresh,
        onMMPulling: this._onPulling,
        onMMReleaseToRefresh: this._onReleaseToRefresh,
        onMMRefreshIdle: this._onMMRefreshIdle,
        
      }
    }
    return (
      <RCTMMRefreshView
        ref={ref => this.refreshViewRef = ref}
        {...nativeProps}
      >
        <View style={{ height: 130, backgroundColor: 'red', alignItems: 'center', justifyContent: 'center' }}><Text>我是refreshControl</Text></View>
      </RCTMMRefreshView>

    )
  }
}

// Object-C 
// RCTMMRefreshViewManager.m
...
...

-(UIView *)view
{
    header=[RCTMMRefreshHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
    return header;
}

...
...

// RCTMMRefreshHeader.h
@interface RCTMMRefreshHeader : MJRefreshHeader


// MJRefresh/Base/RefreshComponent.h
#import <React/RCTView.h>
#import <React/UIView+React.h>

// MMScrollView 这个控件和 RN 内置的ScrollView 没什么很大变化
// MMScrollView.m   
...
#import "MJRefresh.h"

...
...
- (void)insertReactSubview:(UIView *)view atIndex:(NSInteger)atIndex
{
  ...
  if ([view isKindOfClass:[MJRefreshHeader class]]){
    _scrollView.mj_header = (MJRefreshHeader *)view;
  }
}
...
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions