不明白为什么"标签"当我点击单元格表时弹出

时间:2016-02-04 01:26:22

标签: ios swift uitableview

Before tapping the cell

After tapping the cell

点击细胞后

我不明白为什么单词"标签"点击UITableView

中的单元格时会不断弹出
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell
    cell.textLabel?.text = categories[indexPath.row]
    cell.imageView?.image = normal_icons[indexPath.row]
    return cell
}

func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
    let cell = tableView.cellForRowAtIndexPath(indexPath)
    cell?.accessoryType = UITableViewCellAccessoryType.None
    cell?.textLabel?.textColor = UIColor.blackColor()
    cell?.imageView?.image = normal_icons[indexPath.row]
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    let cell = tableView.cellForRowAtIndexPath(indexPath)
    cell?.accessoryType = UITableViewCellAccessoryType.Checkmark
    cell?.textLabel?.textColor = UIColor.blueColor()
    cell?.imageView?.image = active_icons[indexPath.row]
    cell!.detailTextLabel?.text =  " "
}

表格单元格类型为

enter image description here

2 个答案:

答案 0 :(得分:1)

更改

        function Get-ScriptDirectory 
{ 
    $Invocation = (Get-Variable MyInvocation -Scope 1).Value 
    Split-Path $Invocation.MyCommand.Path 
    #Split-Path -Path $($global:MyInvocation.MyCommand.Path)
    #split-path -parent $psISE.CurrentFile.Fullpath
}

$ScriptRoot = Get-ScriptDirectory

$CurrentPath = $ScriptRoot.ToString()
$Configfile= [xml](get-content "$Currentpath\Config.xml")



# Import variables from XML configuration file
$Configfile= [xml](get-content "$Currentpath\config.xml")


# Get SCCM sourcefile location Options

$Source=$Configfile.config.SCCMClient.SourceDIR
$ExecutableName=$Configfile.config.SCCMClient.FileName
# Get SCCM Options

$configSMSSitecode =$Configfile.config.SCCMConfig.SMSSITECODE
$configManagementPoint = $Configfile.config.SCCMConfig.MP
[int]$configCacheSize = $Configfile.config.SCCMConfig.SCCMCACHE

#=======================================================================================
# SCCM Command line Arguments for Installing SCCM Client

#=======================================================================================

$arguments="/mp:`"$configManagementPoint`" /logon SMSSITECODE=`"$configSMSSitecode`""

function Install-SCCMclient
<# 
.SYNOPSIS
    Function to Install SCCM Client.
.DESCRIPTION
    Function to Install SCCM Client SCCM Client using SWITCHES
.EXAMPLE
    Install-SCCMclient
.PARAMETER Path
    Path of the Source file path 
.PARAMETER ContinueOnError
    Continue if an error is encountered
.NOTES 

#>
{
Param(
        [Parameter(Mandatory = $false)]
        [String] $executablename="ccmsetup.exe",
        [boolean] $ContinueOnError = $true
    )  
    Try{
            $returncode=$null
            if((Test-path $source) -eq $true)
            {

                write-Host "SCCM Source file location path Resolved"
            }
            else{

                write-Host " Unable to resolve SCCM Source file ccmsetup.exe path"
                Exit-script 5020
            }


            #Installs SCCM Client using Switches and captures exits code for Installation
            $process = (Start-Process -WorkingDirectory "$source" -FilePath "$ExecutableName" -ArgumentList "$arguments" -PassThru -Wait)

                #Start-Sleep -s 180
            # Get the exit code for the process

            $returnCode = $process.ExitCode
                if($returncode -eq 0)
                {

                 Write-Host "SCCM Installation Process finished with following exitcode:[$returnCode] " 

                }
                else{
                    Write-Host "SCCM Installation Process Failed with following exitcode:[$returnCode] "
                    }
                    #Write-Host "SCCM Installation Process finished with return code: " $process.Exitcode   
                    #Write-Host "$returnCode"   

        }


Catch [Exception] {
        If ($ContinueOnError -eq $true) {
            Write-Host $("SCCM Client instalaltion completed with the following exit code:" + $_.Exception.Message)
            Continue
        }
        Else {
            Throw $("Could not Install] SCCMClient:" + $_.Exception.Message)
        }
    }
}     
Install-SCCMClient

func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath)

请注意您的取消选择 RowAtIndexPath并执行选择 RowAtIndexPath

但是我相信即使将didDeselect更改为didSelect

,也会有更多问题

答案 1 :(得分:0)

您是否正在更改didSelectRowAtIndexPath中的detailTextLabel?这可能是问题所在。尝试将其设置为空字符串以确认是否确实是问题。