0

I am trying to code a tableview with words on the left and buttons on the right for each row. Is that possible to do?

I have got the words coded for each row however I am struggling with putting the buttons on the right side and spaced evenly as well as following the screen when scrolling up and down the tableview.

At the moment I have just been adjusting the button's y axis numbers from the right side controls in the x code to make sure the buttons are evenly spaced but it is not following the scroll. Is there is an easier or more efficient way of doing this? Any help would be great.

Thanks!

1
  • You should definitely put some effort to learn AutoLayout. Commented Feb 11, 2015 at 11:20

1 Answer 1

1

You should create your own UITableViewCell. Apple has a tutorial in their documentation how to do that. It's written for Objective-c, but you can easily change it to swift. Also there are tutorials like this tutorial on YouTube.

Basically, what you need to do is creating a UITableViewCell and use it instead of the normal UITableViewCell in the cellForRowAtIndexPath. After that, you can add whatever elements you'd like to have.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks! I think that would be useful! I will give that a try! I am quite new at this though I am unsure how to change it to swift. Any tips? :)
I've added a link to a tutorial on Youtube which does that in swift. :)
If my answer solved your problem, please accept my answer by clicking on the tick. So other people find the answer easier.
I gave the video a go and it didn't run at all. Firstly when I created my customcell.swift file the initialising code was missing and even when i typed it in it keeps coming up with a thread 1: EXC_BAD_INSTRUCTION have no idea why. This is the code that comes up with the error. let cell: CustomCell = tableView.dequeueReusableCellWithIdentifier("Cell") as CustomCell Not sure what is wrong with it or how to fix it. Any ideas?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy 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.