1

I'm new to IOS development, I have a few questions.

1) What's the purpose of property rowheight on table view cell, I mean it does nothing even if I change its value, it always takes the value from its parent view i.e a tableview property rowheight? It visually changes in the IB but nothing happens when I run the app.

2) What's the purpose of Content View why is it even there? Let's say If I have to make some image equal to the height of the cell it restricts me. Or is there any way a content view can be changed to be equal to the cell height & width? I have to put constraints on the image in relation with the cell which is not the immediate parent of the image and I don't know if this is the correct way to do it.

3)How does Xcode Autocomplete works? like if I want to write a function tableview(_:tableview didselectrowwithindex:IndexPath) and I type tableview it shows a list, what to do next? I mean I can't type the whole fucntion with params or find the func in the huge list.

gamer
  • 105
  • 11
  • Three questions! - Might be worth asking some of these in separate threads - especially the `UITableView` related ones. You may even find some of these have answers already. – Wez Feb 18 '16 at 11:28

2 Answers2

1

The height of the cell set at the IB is primarily used for simulation, the views described at IB are normally resized when actually used. E.g. you can set rows height to be 100 for the table view, 30 for some of the cells and keep the whole controller simulating a nice screen of iPhone 6. The same view will be used for all devices and will be scaled accordingly as well as the cells with the help of your delegate.

The content view is there for the reasons directly related to your additional requests. It holds all the content while there other views that accompany your content and are part of the cell like separators, accessory views, slide action views. Without a content view the responsibility of managing all the additional parts would most likely fall on you as a developer and while you might think that that is fine at the simple layouts, a simple enhancement to it would make a huge impact.

Fuzzy autocompletion at Xcode seems to be something Apple is working on now. If you can't wait and find it too difficult to navigate through the list, there are Xcode plugins available that provide fuzzy autocompletion.

A-Live
  • 8,904
  • 2
  • 39
  • 74
  • yeah I thought so the autocomplete sucks ATM. names are not unique. Going through the Apple doc and your comment I understand about content view. But the I still cant understand RowHeight. Why is the rowhieght property even there on cellview if it cant do anything. It always takes the value of rowheight from tableview. – gamer Feb 18 '16 at 12:55
  • 1
    Normally you will provide the rows height through the delegate, not interface builder. The option to set it at IB is most often used to simulate different sizes and observe the cell's behavior. Same as view controller simulated metrics, it doesn't provide a finishing look but renders the view close as to how it will appear in different situations. – A-Live Feb 18 '16 at 13:25
  • right .. Can a cell size be smaller or larger than table row size ? – gamer Feb 18 '16 at 14:09
  • I agree with A-Live. The delegate function - tableView:heightForRowAtIndexPath: is the only way I'm sure the height is going to be what I want it – Tomek Feb 18 '16 at 14:09
  • Yes, the cell height can be of any value, different or same as set at the tableview - that should not break anything. I don't remember any project actually using the cells size set at the tableview itself because the approach is too limited, it can be used alone for very basic layouts or a quick preview at IB though. – A-Live Feb 18 '16 at 15:10
0

Answering the question in the topic:

example: tableview(_:tableview didselectrowwithindex:IndexPath) if you write tableview it will show all the symbols that start with tableview. For functions, it will show all the functions sorted by the second parameter name (didSelectRowWithIndex).

[EDIT] it will autocomplete as far as the answer is unique and then show you a list full of options. I don't know any tricks to skip looking through the massive list. But after a while you'll know what you're looking for and it gets faster. [\EDIT]

when you press tab, it by the way: the delegate functions names start with the name of the object they're related to. So UITableViewDelegate functions start with tableview.

as for your first two questions there are tons of answers for those questions on SO. This one seems closely related to yours.

Community
  • 1
  • 1
Tomek
  • 607
  • 9
  • 16