我想我的iOS App的主模块编译Swift 4.0,而CocoaPods模块编译swift 3.
PS:使用Xcode 9 beta 2.
LinearLayout bottomSheetViewgroup = (LinearLayout) findViewById(R.id.bottomSheet);
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetViewgroup);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); //this line
Run Code Online (Sandbox Code Playgroud)
我在我的activity的onCreate()方法中有这个代码,当执行最后一行时,我得到了下面的NPE异常:
引发者:java.lang.NullPointerException:尝试在android.support.design.widget.BottomSheetBehavior.setState上的空对象引用上调用虚方法'java.lang.Object java.lang.ref.WeakReference.get()'( BottomSheetBehavior.java:440)
android nullpointerexception android-appcompat material-design
在swift 3开发时,我习惯写:
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.orange]
Run Code Online (Sandbox Code Playgroud)
将它放在AppDelegate中会将所有UINavbars的标题颜色更改为橙色.
现在我想对Swift 4和iOS 11做同样的事情.
我正在尝试运行以下行:
guard let spriteComponent = entity?.componentForClass(SpriteComponent.self) else {
return
}
Run Code Online (Sandbox Code Playgroud)
并收到此:
类型“ GKEntity”的值没有成员“ componentForClass”
显然,苹果从GamePlayKit GkEntity类中删除了此方法。那么我应该使用哪种方法呢?
ios ×3
android ×2
swift ×2
swift3 ×2
swift4 ×2
cocoapods ×1
gameplay-kit ×1
sprite-kit ×1
uikit ×1
xcode9-beta ×1