小编Axe*_*Ros的帖子

React-Native 博览会 POST Blob

我在 expo 中使用 react native,我正在尝试通过 fetch api 发布 blob 图像。我正在为正文使用表单数据格式,并且我有下一个代码:

       const blob = await response.blob()
       const form = new FormData()
        form.append('file', blob)
        const options: RequestInit = {
            method: 'POST',
            headers,
            body: form
        }
        return this.fetch(path, options).then(res => {
            console.log("FETCHING", res.status)
            this.processResponse(path, options, res)
        }).catch(err => {
            console.log("FETCH ERROR", err)
        })
Run Code Online (Sandbox Code Playgroud)

响应从未发生,我的控制台显示“FETCH ERROR [TypeError: Network request failed]”。任何的想法?

之前的感谢

javascript typescript react-native expo

9
推荐指数
1
解决办法
488
查看次数

React Native 博览会相机景观视频

我正在以不同的方向(横向和纵向)录制一些视频,但我的应用程序被迫通过配置处于纵向模式。问题是每条记录的结果都是纵向保存的。

有没有办法在不改变配置的情况下决定结果方向?

这是我的相机组件:

import { Camera } from 'expo-camera'

...

private onStartRecording = () => {
    if (this.ref.current && this.state.isCameraReady && this.isRightOrientation()) {
      this.setState({ fileUrl: '', isRecording: true })
      this.ref.current.recordAsync({ quality: '720p' })
        .then((file) => {
          if (this.props.format === 'horizontal' && !this.props.isVideo)
            ImageManipulator.manipulateAsync(
              file.uri,
              [{ rotate: this.state.orientation }, { flip: ImageManipulator.FlipType.Horizontal }],
            ).then(file => {
              this.setState({ fileUrl: file.uri })
            }).then(error => console.log("Error", error))
          else {
            this.setState({ fileUrl: file.uri })
          }
        }).catch(error => console.log("Error", error));
    }
  }

...

return (
  <Camera …
Run Code Online (Sandbox Code Playgroud)

javascript typescript react-native expo expo-camera

5
推荐指数
0
解决办法
788
查看次数

片段内的Kotlin按钮onClickListener事件

我试图从片段内的按钮捕获onClick事件,但它不起作用.

有提示吗?

我有这个主要活动,我通过bottomNavigation调用片段.MainActivity.kt:

    class MainActivity : FragmentActivity()  {

    private val mOnNavigationItemSelectedListener = BottomNavigationView.OnNavigationItemSelectedListener { item ->
        when (item.itemId) {
            R.id.navigation_home -> {
                showFragmentSetup()
                return@OnNavigationItemSelectedListener true
            }
        }
        false
    }

    fun showFragmentSetup(){
        val setupFragment = SetupFragment()
        val manager = supportFragmentManager
        val transaction = manager.beginTransaction()
        transaction.replace(R.id.setupFragment, setupFragment)
        transaction.addToBackStack(null)
        transaction.commit()
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
    }
}
Run Code Online (Sandbox Code Playgroud)

activity_main.xml是linearLayout的容器,它将组合片段.

activity_main.xml中

    <LinearLayout
        android:id="@+id/setupFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        />
Run Code Online (Sandbox Code Playgroud)

我的片段很简单它只有一个按钮,我想从这个按钮捕获onClickEvent

    class SetupFragment : Fragment(){

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, …
Run Code Online (Sandbox Code Playgroud)

events android android-fragments kotlin

3
推荐指数
2
解决办法
1万
查看次数