我的应用程序中的组件如果被分配了直接字符串值("someImage.png"),它可以正常工作,但如果我尝试通过将图像名称存储在局部变量中来分配它,则会给出此异常"require()必须具有单个字符串文字参数"此行正常工作
<ImageBackground source={require("./Resources/bg/imageone.png")} resizeMode='cover' style={customStyles.backdrop}>
Run Code Online (Sandbox Code Playgroud)
在这种情况下会出现问题
let imageName = "./Resources/bg/imageone.png";
<ImageBackground id="123" source={require(imageName)} resizeMode='cover' style={customStyles.backdrop}>
Run Code Online (Sandbox Code Playgroud)
我在我的应用程序中使用 pageViewController 当它的父视图被推送到导航堆栈时工作正常,但是当它的父视图显示在窗口中时,它会在导航到下一个 viewController 时崩溃,但异常。
无效参数不满足:[views count] == 3
配置为:
transitionStyle = .scroll
setViewControllers(...animated:true...)
Run Code Online (Sandbox Code Playgroud)
StackOverflow 上已经有很多关于此的问题。
Crash1提供了两种解决方案,但一种不适用于我的情况。(textField) 和其他不起作用 (DispathMainQueue)。
Crash2,我试过在里面设置视图控制器DisptachMainQueue但它不起作用,设置setViewControllers(...animated:false...)和transitionStyle: .pageCurl工作但是有没有其他方法可以使用animated:true和transitionStyle: .scroll使用 Swift 4?