0

Im new to xcode and was trying to add different images in a table row in a storyboard layout.

let image:UIImage = UIImage(named:”ster.jpg")!

when i use this code, it makes every table the same image

 let image:UIImage = UIImage(named:    ”ster.jpg", "blue.jpg")!

My goal is for the 2nd row of the table to have a different image, so when using this code it just creates an error saying " Extra argument in call"

askedOct 3, 2022 at 7:16
nothing's user avatar
2
  • You need to create another image and assign it to the second image view.CommentedOct 3, 2022 at 7:20
  • In your table data source set the image according to the indexPath.row value.CommentedOct 3, 2022 at 8:20

1 Answer1

0

I would start by saying that the way you initialize the UIImage object is wrong. It supports only one image at a time. Thus, you get the error of an extra argument in the call.

To add two images in a row, you better use a horizontal stack view and modify some of its properties (fill equally, spacing, etc).

The way I would do the thing: Drag and drop from library 2 UIImage objects. Embed them in a horizontal stack view. In property inspector set the fill property to equal. Make sure to add constraints.

In case you are using UITableView and want to modify the cell, you will have to create a subclass of UITableViewCell and give it an identifier to use when the TableViewDataSourceDelegate object is fetching the cell data based on the identifier.

answeredOct 3, 2022 at 8:38
Alexander's user avatar
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.