Swift tableview单元格不显示部分的背景图像

时间:2016-09-20 21:19:35

标签: ios iphone swift

在cellForRowAtIndexPath方法中,我正在向单元格分配一个像这样的背景图像:

Sub ImportAllCSV()
  Dim FName As Variant, R As Long
    Application.ScreenUpdating = False
        R = 1
        Set CurrWB = Workbooks("Bok1.xlsm")
        directory = CurrWB.Path & "\"
        FName = Dir(directory & "*.csv")
            Do While FName <> ""
              ImportCsvFile FName, ActiveSheet.Cells(R, 1), directory
              R = ActiveSheet.UsedRange.Rows.Count + 1
              FName = Dir
            Loop

                Call KopieraUnikaRaderBlad
                Call RaderaLine
                Call SammanStall
                Call SidforNummer
                Call KollaFlyttaData
               'Call RäknaData
    Application.ScreenUpdating = True
    End Sub

Sub ImportCsvFile(FileName As Variant, Position As Range, directory As Variant)
Dim newString As String
Dim char As Variant
      ActiveWorkbook.Worksheets.Add
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;" & directory & FileName _
        , Destination:=Range("$A$1"))
        .Name = "A00-40---1-D02------ Klar_allt" 'vet inte vad den här linjen gör verkar som inget
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 65001
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileOtherDelimiter = ";"
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
        .WorkbookConnection.Delete
    End With
    ' det som är in kopierat några kolumner tas bort
    Columns("C:I").Select
    Selection.Delete Shift:=xlToLeft
    Range("A1").Select
    newString = Right(FileName, 25)
    'fixar till bladnamnet
    For Each char In Split(SpecialCharacters, ",")
        newString = Replace(newString, char, "")
    Next
    ActiveSheet.Name = Left(newString, Len(newString) - 3)
End Sub

但细胞似乎是一样的。如何纠正这个?

2 个答案:

答案 0 :(得分:0)

您正在创建UIImageView的实例而不设置其框架。

例如设置imageView.frame = CGRect(x: 0, y: 0, width: 100, height: 200)以设置其框架并使其可见。

您也可以在创建框架时直接设置框架:

let imageView = UIImageView(frame:CGRectMake(0, 0, 100, 200))

然后您可以使用以下方式设置图像:

imageView.image = UIImage(named: "other_car")

imageView.image = image // your UIImage instance

答案 1 :(得分:0)

我错过的是:在更改cell.backgroundView = imageView之前我插入了这段代码,它清除了单元格内的颜色:

cell.backgroundColor = UIColor.clearColor()

希望它可以帮助其他人