如何设置图像信息的分辨率?

时间:2019-03-26 20:57:29

标签: react-native react-native-gifted-chat

我正在为我的应用程序使用天才聊天。发送文本和图像消息。

我在android部分没有问题。但是在ios设备中,我在全页预览中显示的图像质量非常低。即使在我的android设备上看起来还不错,我什至无法在ios部分上读取图像中的一些文本。

可能是什么原因?有没有可能设置图像分辨率的方法?还是可以针对特定平台?

这是代码, 这是我获取数据的地方:

getData() {
  postRequest('messages', { chatId: this.props.userToChat.id, page: this.state.page, size: 30 })
    .then((response) => {
      if (response.data.status < 200 || response.data.status > 300) {
        return null;
      }
      const messages = response.data.data.map(message => this.handleMessages(message));
      this.setState({
        messages,
      });
    })
    .catch(() => {
      Toast.show('Bağlantı hatası');
    });
}

这是handleMessage方法:

handleMessages(msg) {
  let msgObj = {};
  if (msg.dataType === 'TEXT') {
    msgObj = this.handleTextMessages(msg);
  } else {
    msgObj = this.handleImageMessages(msg);
  }
  return msgObj;
}

这是handleImageMes​​sages:

handleImageMessages(messageObj) {
  const obj = {
    _id: messageObj.id,
    image: messageObj.content,
    createdAt: new Date(messageObj.date),
    user: {
      _id: messageObj.sender,
      avatar: this.props.userToChat.photo === '' ? null : this.props.userToChat.photo,
    },
  };
  return obj;
}

这是GiftedChat的定义:

<GiftedChat
          messages={this.state.messages}
          user={{
            _id: this.userId,
          }}
          placeholder="Mesaj Yazınız..."
          onSend={messages => this.onSend(messages)}
          renderComposer={this.renderComposer}
          maxComposerHeight={80}
          renderLoadEarlier={this.renderLoadEarlier}
          loadEarlier={this.state.loadEarlier}
          onLoadEarlier={this.onLoadEarlier}
          isLoadingEarlier={this.state.isLoadingEarlier}
        />

谢谢

0 个答案:

没有答案
相关问题