How do I write a swift array that can make the same UIImage appear for all my dynamic cells?

Shikinr

For my dynamic prototype tableview I have 135 cells. So i created a variable array:

var myLife = Array(count: 135, repeatedValue: "My Cell")

I have a mycell.jpg that I want to display on every one of those 135 cells, but i ended up writing mycell.jpg 135 times in this array cos I only know of this way to write the array for images.

var myCellImage = ["mycell.jpg", "mycell.jpg", "mycell.jpg", "mycell.jpg",......]

Is there a better code? Can anyone help me?

Christian

You've got a method called cellForRowAtIndexPath in your UITableView. This method gets called for each cell.

So, in there you can set the picture once and it will be set for every cell:

func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!  {
    var cell = tableView.dequeueReusableCellWithIdentifier("YourCellIdentifier") as? UITableViewCell

    if cell == nil {
        cell = UITableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "YourCellIdentifier")
    }

    cell.imageView = UIImage(named: "mycell.jpg")

    return cell
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I make my output appear all on one line with no spaces?

From Dev

How do I filter my table view cells so that the cells filtered out do not appear?

From Dev

How do I make an UIImage/-View with rounded corners CGRect (Swift)

From Dev

How can I find all the cells that have the same values in a multi-dimensional array in octave / matlab

From Dev

How can I order two dynamic table view cells in swift?

From Dev

How can I make my app appear in UIActivityViewController for text?

From Dev

How can i make my app appear on tablets

From Dev

How can I make my OS appear as if it is running virtualized?

From Dev

How can I make my navbar appear at a certain section?

From Dev

How do I make my app appear in app chooser?

From Dev

How do I make my menu appear on click with css

From Dev

How can I get all of my GMail directories to appear in Thunderbird?

From Dev

How do I make a border around my whole screen for all the devices in Swift Xcode?

From Dev

How can I make an immutable Array in swift that has different instances of the same class

From Dev

How can I make my JTable/TableModel dynamic?

From Dev

How can I make my express route more dynamic

From Dev

How do I make my column dynamic in HTML

From Dev

How do I make the name of my object dynamic

From Dev

How can I make a container with copy-on-write semantics? (Swift)

From Dev

How can I make my navbar appear on every page in my rails app?

From Dev

How do I make my repo appear on my Github Desktop (Github for Windows)?

From Dev

How can i print my array and my histogram on the same line?

From Dev

How do I write map that works for all types in Swift?

From Dev

IOS swift How can I get my SubView to appear below my SearchBar

From Dev

Awesome WM : How can I write a rule to make a window appear floating under the mouse?

From Dev

How can I make my main if, elseIf and else to do the same thing as my main if does without getting "duplicate" errors?

From Dev

How can I make dynamic associative array with jquery?

From Dev

How can I make my borders the same size?

From Dev

How do I make array dynamic in LATERAL VIEW EXPLODE?

Related Related

  1. 1

    How can I make my output appear all on one line with no spaces?

  2. 2

    How do I filter my table view cells so that the cells filtered out do not appear?

  3. 3

    How do I make an UIImage/-View with rounded corners CGRect (Swift)

  4. 4

    How can I find all the cells that have the same values in a multi-dimensional array in octave / matlab

  5. 5

    How can I order two dynamic table view cells in swift?

  6. 6

    How can I make my app appear in UIActivityViewController for text?

  7. 7

    How can i make my app appear on tablets

  8. 8

    How can I make my OS appear as if it is running virtualized?

  9. 9

    How can I make my navbar appear at a certain section?

  10. 10

    How do I make my app appear in app chooser?

  11. 11

    How do I make my menu appear on click with css

  12. 12

    How can I get all of my GMail directories to appear in Thunderbird?

  13. 13

    How do I make a border around my whole screen for all the devices in Swift Xcode?

  14. 14

    How can I make an immutable Array in swift that has different instances of the same class

  15. 15

    How can I make my JTable/TableModel dynamic?

  16. 16

    How can I make my express route more dynamic

  17. 17

    How do I make my column dynamic in HTML

  18. 18

    How do I make the name of my object dynamic

  19. 19

    How can I make a container with copy-on-write semantics? (Swift)

  20. 20

    How can I make my navbar appear on every page in my rails app?

  21. 21

    How do I make my repo appear on my Github Desktop (Github for Windows)?

  22. 22

    How can i print my array and my histogram on the same line?

  23. 23

    How do I write map that works for all types in Swift?

  24. 24

    IOS swift How can I get my SubView to appear below my SearchBar

  25. 25

    Awesome WM : How can I write a rule to make a window appear floating under the mouse?

  26. 26

    How can I make my main if, elseIf and else to do the same thing as my main if does without getting "duplicate" errors?

  27. 27

    How can I make dynamic associative array with jquery?

  28. 28

    How can I make my borders the same size?

  29. 29

    How do I make array dynamic in LATERAL VIEW EXPLODE?

HotTag

Archive