更新UITableViewCell

时间:2017-08-02 17:06:37

标签: ios swift uitableview

我遇到了问题。我有这个tableview和这个pickerView change the existing image

这是viewcontroller的pickerView函数:

Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]

Configuration on demand is an incubating feature.
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Configuration 'androidTestCompile' in project ':app' is deprecated. Use 'androidTestImplementation' instead.
Configuration 'testCompile' in project ':app' is deprecated. Use 'testImplementation' instead.
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
:app:preBuild UP-TO-DATE
:app:preDebugBuild
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources
:app:generateDebugSources
:app:preDebugAndroidTestBuild
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources UP-TO-DATE
:app:splitsDiscoveryTaskDebugAndroidTest UP-TO-DATE
:app:processDebugAndroidTestResources UP-TO-DATE
:app:generateDebugAndroidTestSources UP-TO-DATE
:app:mockableAndroidJar UP-TO-DATE

BUILD SUCCESSFUL in 1s
21 actionable tasks: 5 executed, 16 up-to-date
Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]

Configuration on demand is an incubating feature.
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Configuration 'androidTestCompile' in project ':app' is deprecated. Use 'androidTestImplementation' instead.
Configuration 'testCompile' in project ':app' is deprecated. Use 'testImplementation' instead.
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
:clean
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:checkDebugManifest
:app:generateDebugBuildConfig
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResources
:app:createDebugCompatibleScreenManifests
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug
:app:processDebugResources
:app:generateDebugSources
:app:preDebugAndroidTestBuild
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:generateDebugAndroidTestResValues
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:splitsDiscoveryTaskDebugAndroidTest
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:mockableAndroidJar

BUILD SUCCESSFUL in 2s
23 actionable tasks: 23 executed
Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Configuration 'androidTestCompile' in project ':app' is deprecated. Use 'androidTestImplementation' instead.
Configuration 'testCompile' in project ':app' is deprecated. Use 'testImplementation' instead.
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
'kapt.generateStubs' is not used by the 'kotlin-kapt' plugin
:app:buildInfoDebugLoader
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources
:app:kaptGenerateStubsDebugKotlin
Using kotlin incremental compilation
:app:kaptDebugKotlin
w: warning: Supported source version 'RELEASE_7' from annotation processor 'android.arch.persistence.room.RoomProcessor' less than -source '1.8'
w: 

w: /Users/maxgierlachowski/Projects/jooy/app/build/tmp/kapt3/stubs/debug/com/jooyapp/jooy/Persistence/Entities/Message.java:17: warning: Primary key constraint on chatId is ignored when being merged into com.jooyapp.jooy.Persistence.Entities.Message
w: 

w:     private com.jooyapp.jooy.Persistence.Entities.Chat chat;
w:                                                        ^
w: /Users/maxgierlachowski/Projects/jooy/app/build/tmp/kapt3/stubs/debug/com/jooyapp/jooy/Persistence/Entities/Message.java:20: warning: Primary key constraint on userId is ignored when being merged into com.jooyapp.jooy.Persistence.Entities.Message
w: 

w:     private com.jooyapp.jooy.Persistence.Entities.User user;
w:                                                        ^

e: /Users/maxgierlachowski/Projects/jooy/app/build/tmp/kapt3/stubs/debug/com/jooyapp/jooy/Persistence/DatabaseAccessObjects/ChatDataAccessObject.java:19: error: no viable alternative at input 'chat_id'
e: 

e:     public abstract com.jooyapp.jooy.Persistence.Entities.Chat getChat(@org.jetbrains.annotations.NotNull()
e:                                                                ^
e: /Users/maxgierlachowski/Projects/jooy/app/build/tmp/kapt3/stubs/debug/com/jooyapp/jooy/Persistence/DatabaseAccessObjects/UserDataAccessObject.java:9: error: no viable alternative at input 'user_id'
e: 

e:     public abstract com.jooyapp.jooy.Persistence.Entities.User getUser(@org.jetbrains.annotations.NotNull()
e:                                                                ^

w: warning: Supported source version 'RELEASE_7' from annotation processor 'android.arch.lifecycle.LifecycleProcessor' less than -source '1.8'
w: 


e: java.lang.IllegalStateException: failed to analyze: org.jetbrains.kotlin.kapt3.diagnostic.KaptError: Error while annotation processing
    at org.jetbrains.kotlin.analyzer.AnalysisResult.throwIfError(AnalysisResult.kt:57)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:144)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:167)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:55)
    at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.java:182)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.execCompiler(CompileServiceImpl.kt:397)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$execCompiler(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$2.invoke(CompileServiceImpl.kt:365)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1$2.invoke(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2$$special$$inlined$withValidClientOrSessionProxy$lambda$1.invoke(CompileServiceImpl.kt:798)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2$$special$$inlined$withValidClientOrSessionProxy$lambda$1.invoke(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.common.DummyProfiler.withMeasure(PerfUtils.kt:137)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.checkedCompile(CompileServiceImpl.kt:825)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$checkedCompile(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2.invoke(CompileServiceImpl.kt:797)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$doCompile$2.invoke(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive(CompileServiceImpl.kt:1004)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive$default(CompileServiceImpl.kt:865)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.doCompile(CompileServiceImpl.kt:791)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.access$doCompile(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1.invoke(CompileServiceImpl.kt:364)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl$compile$1.invoke(CompileServiceImpl.kt:99)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive(CompileServiceImpl.kt:1004)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.ifAlive$default(CompileServiceImpl.kt:865)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:336)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
    at sun.rmi.transport.Transport$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.jetbrains.kotlin.kapt3.diagnostic.KaptError: Error while annotation processing
    at org.jetbrains.kotlin.kapt3.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:90)
    at org.jetbrains.kotlin.kapt3.AnnotationProcessingKt.doAnnotationProcessing$default(annotationProcessing.kt:42)
    at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.runAnnotationProcessing(Kapt3Extension.kt:205)
    at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:166)
    at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:82)
    at org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM$analyzeFilesWithJavaIntegration$2.invoke(TopDownAnalyzerFacadeForJVM.kt:89)
    at org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:99)
    at org.jetbrains.kotlin.resolve.jvm.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:76)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.analyze(KotlinToJVMBytecodeCompiler.kt:365)
    at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:105)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:354)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.kt:139)
    ... 40 more


:app:kaptDebugKotlin FAILED
:app:buildInfoGeneratorDebug

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> Internal compiler error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED in 3s

15 actionable tasks: 6 executed, 9 up-to-date

如何修改" m"在选择了uipicker的单元格中?谢谢大家!

3 个答案:

答案 0 :(得分:0)

我假设你想让你的M和F出现在你的pickerView中。为此,您必须创建一个引用。这可以通过import UIKit import UIKit.UIGestureRecognizerSubclass class MyRecognizer: UIGestureRecognizer { override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) { super.touchesBegan(touches, with: event) if touches.count != 1 { state = .failed return } print(self.state.rawValue) self.state = .began } override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent) { super.touchesMoved(touches, with: event) print("moved", self.state.rawValue) } } class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let g = MyRecognizer(target: self, action: #selector(grFired)) self.view.addGestureRecognizer(g) // Do any additional setup after loading the view, typically from a nib. } @objc func grFired(_ g:UIGestureRecognizer) { print("here", g.state.rawValue) } } 完成,也可以通过编程方式执行:IBOutlet。另外,我还假设您在视图控制器中仅使用一个let pickerView = UIPickerView()。如果您使用的是多个,请为每个pickerView设置一个标记。这可以在界面构建器中完成,并以编程方式完成:pickerView。然后根据这些标签更改pickerView功能。

答案 1 :(得分:0)

创建变量

var currentGender = "M"

将TableViewCell设置为currentGender,如

cell.gender = currentGender

UIPickerView中选择一行时,

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    currentGender = gender[row]
    // Then reload your TableView row
    let indexPath = IndexPath(item: rowNumber, section: 0)
    tableView.reloadRows(at: [indexPath], with: .top)
}

答案 2 :(得分:0)

  1. 创建变量。      var gender =&#34; M&#34;
  2. 再次初始化您的性别变量。在这个委托方法中。   func pickerView(_ pickerView:UIPickerView,didSelectRow row:Int,inComponent component:Int){ 性别=性别[排] //然后重新加载TableView行 table view.reloadData() }

  3. 将这些行添加到您的cellforrow_atIndexPath。 Cell.genderIdicatorLbl.text =性别 注意:genderIndicatorLbl是您的性别指标标签

  4. 的IBOutlet