我有一个TabView
inSwiftUI
并且希望在启动应用程序时将第二个选项卡设为默认选项卡。
我还没有找到任何文档来提供这种行为,但应该是可能的。大多数应用程序都将中间选项卡作为默认选项卡。
TabView {
QuestionView()
.tabItem {
Image(systemName: "questionmark")
Text("Questions")
}
DataView()
.tabItem {
Image(systemName: "chart.bar.fill")
Text("Data")
}
Text("Empty Tab right now")
.tabItem {
Image(systemName: "bolt.horizontal.fill")
Text("Trend")
}
}
Run Code Online (Sandbox Code Playgroud) 我工作ViewModels
和LiveData
Android应用中,我想用它来跟踪数据,即使当屏幕旋转时的活动。这很有效,但有一个我无法解决的问题。在 Activity 的onCreate
方法中,我为包含对象列表的 LiveData 注册了一个观察者,如果加载了数据,它应该只向活动添加一个 Fragment。然后,如果savedInstanceState
为空,我只重新加载数据,这应该会阻止它在屏幕旋转时重新加载。这看起来像这样:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
model = ViewModelProviders.of(this).get(MainActivityModel.class);
observeList();
if (savedInstanceState == null) {
loadList(); //Reload the list and call postValue() on the LiveData.
}
}
private void observeList() {
model.getList().observe(this, new Observer<ArrayList<Object>>(){
@Override
public void onChanged(@Nullable ArrayList<Object> objects) {
//Add list fragment whenever data changes.
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, ListFragment.getInstance(list))
.commit();
}
});
}
Run Code Online (Sandbox Code Playgroud)
根据我的理解,ListFragment 只应在数据更改时显示。但是,经过一些调试后,似乎onChanged
每次旋转屏幕时都会调用 observeList 方法中的方法。此外,我检查了实际列表是否已更改并且完全相同,完全没有区别,甚至从来没有postValue(
) 或setValue() …
当我有 aTabView{}
并且第一个 Tab 有 a 时NavigationView
,当我点击 a 时Row
,我希望它TabView{}
消失。我怎么做?
同样的问题:在 SwiftUI 中使用 NavigationLink 导航时如何隐藏 TabBar?
但不幸的是没有解决方案。
将iOS PDFView添加到UIView时,PDFView的页面区域会添加阴影样的边框。有消除阴影的方法吗?
我知道一些凌乱的方法可以做到这一点:在屏幕外扩展边界,覆盖白色的UIView以隐藏阴影,或修改私有PDFPageView(以裁剪为边界)。我特别不希望这里的边界越界,并且也不想与其他黑客混在一起。
在尝试归档我的项目时,我收到此错误:
ld: bitcode bundle could not be generated because '/Users//MobileVLCKit/MobileVLCKit.framework/MobileVLCKit(VLCEmbeddedDialogProvider.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build file '/Users//MobileVLCKit/MobileVLCKit.framework/MobileVLCKit' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
尝试这样做,enablebitcode = no
但是当我存档时,mac 卡住了,40 分钟后我放弃了。
知道我能做什么以及是否可以使用此 pod 归档项目?
此异常仅在Tweet Class
使用时发生。我找不到我应该使用的理由Serializable
。我自己在中进行了映射GeneticMessage.hbm.xml
。Tweet类中的所有类型(long和Date)都是Hibernate中的基本类型(我认为是)。
实际上,仅通过实现Exception中提到的Tweet的Serializable可解决该问题。但是我仍然想知道原因。
方法
域domain =(域)对象[0]; 查询q = session.createQuery(“ FROM PreprocessedMessage WHERE domain =?”); q.setEntity(0,domain); 返回q.list(); //这行
例外:
java.lang.ClassCastException:idv.petrie.prtm.model.Tweet无法转换为java.io.Serializable org.hibernate.type.CollectionType.getKeyOfOwner(CollectionType.java:381) org.hibernate.type.CollectionType.resolve(CollectionType.java:425) org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139) org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:982) org.hibernate.loader.Loader.doQuery(Loader.java:857) org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274) org.hibernate.loader.Loader.doList(Loader.java:2533) org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276) org.hibernate.loader.Loader.list(Loader.java:2271) org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452) org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363) org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268) org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) idv.petrie.prtm.model.helper.PreprocessedMessageHelper $ 3.execute(PreprocessedMessageHelper.java:66) idv.petrie.prtm.util.ModelHelper.execute(ModelHelper.java:36) idv.petrie.prtm.model.helper.PreprocessedMessageHelper.findMessageByDomain(PreprocessedMessageHelper.java:69) idv.petrie.prtm.servlet.MessageEvaluationServlet.doGet(MessageEvaluationServlet.java:44) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
PreprocessedMessage.java
软件包idv.petrie.prtm.model; 导入java.util.Collection; 导入java.util.HashSet; 导入java.util.Set; 公共类PreprocessedMessage扩展了GeneticMessage { 私人GeneticMessage消息; 私有集合依赖项; 专用Set令牌; 公共PreprocessedMessage(){ 超(); } public PreprocessedMessage(GeneticMessage消息,字符串内容){ 这个(); this.setMessage(message); this.setContent(content); this.setDomain(message.getDomain()); } public PreprocessedMessage(GeneticMessage消息){ this(message,message.getContent()); } 公共PreprocessedMessage(GeneticMessage消息, 设置依赖项){ 这条信息); this.dependencies =依赖关系; } 公共静态集合convertToCollection( 收藏邮件){ 收集结果= …