Swift:UILabels和UIButtons的问题

时间:2017-03-10 11:34:42

标签: swift uibutton uialertcontroller

我的界面发生了一些奇怪的事情。

首先,当我加载VC时,标签显示的颜色错误。我已经在IB和代码中正确设置了它们,以便进行测量。

接下来,按钮的一些问题。我正在开发一个简单的记分牌应用程序,您可以在其中触摸玩家的分数并加载警报以更新其分数。得分数组正确更新,在调试时可以看到,但得分显示不太合适。以下是问题:

  1. 标签文字被截断。文本的开头是可见的,但是大部分右侧都被切掉,所以通常只显示一位数,或者一位数加上下一位的一小部分。在IB中,按钮肯定足够宽以显示几个数字。按钮处于堆叠视图中,其中包含玩家的名称,并且它们被设置为相等的宽度。 (然后将两个玩家,每个名称标签和分数按钮嵌入另一个堆栈视图中)。 在进一步调查时(将按钮的默认文本从“0”替换为“???”,似乎存在对齐问题。使用默认文本???,输入100作为一个玩家的分数显示“... “对于玩家1和玩家2的0,这两个东西是左对齐的。我没有看到IB中的任何位置来证明按钮的文本,但控件本身是中心对齐的。
  2. 当点击任一分数时,在警报弹出输入分数之前的那一刻,我可以看到两个分数似乎都凸出,这有时会导致数字被椭圆替换(我猜这表示文本大小正在改变,但不是视图的大小。此时,
  3. 有时会重置分数。或者似乎被重置。
  4. 此外,当我输入新的分数时,警报消失后大约一秒钟,按钮显示其默认文本,然后更改显示分数(默认文本设置为“???”总是只需缩小/截断为省略号。
  5. 非常奇怪。这是我的代码。

    16:39:12.653 [localhost-startStop-1] WARN  o.s.c.i.s.PathMatchingResourcePatternResolver - Cannot search for matching files underneath URL [war:file:/C:/Users/user123/apache-tomcat-8.0.41/webapps/project.war*/WEB-INF/classes/package-path/] because it does not correspond to a directory in the file system
    java.io.FileNotFoundException: URL [war:file:/C:/Users/user123/apache-tomcat-8.0.41/webapps/project.war*/WEB-INF/classes/package-path/] cannot be resolved to absolute file path because it does not reside in the file system: war:file:/C:/Users/user123/apache-tomcat-8.0.41/webapps/project.war*/WEB-INF/classes/package-path/
            at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:218) ~[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52) ~[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.core.io.UrlResource.getFile(UrlResource.java:212) ~[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingFileResources(PathMatchingResourcePatternResolver.java:607) [spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.web.context.support.ServletContextResourcePatternResolver.doFindPathMatchingFileResources(ServletContextResourcePatternResolver.java:92)[spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
            at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:420) [spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:274) [spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1269) [spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.buildDefaultPersistenceUnitInfo(DefaultPersistenceUnitManager.java:523) [spring-orm-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.readPersistenceUnitInfos(DefaultPersistenceUnitManager.java:503) [spring-orm-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:440) [spring-orm-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:424) [spring-orm-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:310) [spring-orm-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318) [spring-orm-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) [spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829) [spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) [spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
            at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) [spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4853) [catalina.jar:8.0.41]
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314) [catalina.jar:8.0.41]
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) [catalina.jar:8.0.41]
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753) [catalina.jar:8.0.41]
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729) [catalina.jar:8.0.41]
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) [catalina.jar:8.0.41]
            at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940) [catalina.jar:8.0.41]
            at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816) [catalina.jar:8.0.41]
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_71]
            at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_71]
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_71]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_71]
           at java.lang.Thread.run(Thread.java:745) [na:1.8.0_71]
    

0 个答案:

没有答案