How can I build the following UI item? [duplicate] - ios

This question already has answers here:
How to have one static cell in a dynamic tableview?
(3 answers)
Closed 3 years ago.
I'm trying to make a view similar to the one on the screenshot.
The question is what is the first element(the one with label and chevron)
When I tap on it, it behaves like a table cell(on the screenshot I captured it in tapped state). Thank you!
UPDATE
I ended up creating 2 sections and then checked for index

Looks to me exactly like a standard UITableView cell, with cell.accessoryType = .disclosureIndicator and the background color etc. changed of course.

Honestly looks like the standard table view cell, but you could easily implement this with a custom view (NIB) as well.

You can build this view with UITableViewDelegate like this:
Make a button in the cell and set this image to the button.
Set yourButton.isHidden = true in cellForRowAtIndexPath
Set yourButton.isHidden = false in didSelectRowAtIndextPath
That's it.

Related

How to have different elements in collection view? [duplicate]

This question already has answers here:
Displaying two different cells in a collection view - Swift 2.0 iOS
(2 answers)
Closed 5 years ago.
so I try to have collection view but been thinking is it possible to have different element in each cell view? For Example: in the first cell I have the whole cell covered by UIImageView while some specific cells only got UITextView.
Here's an example that I'm talking about, Medium iOS App.
Create several prototype cells, each formatted with whichever UI elements you want, and dequeue the appropriate cell for each different type of data you want to display.

Swift 3 Show the 'Copy' popup on UITableViewCells when select cell of table like Contaccts app [duplicate]

This question already has an answer here:
How to show "Copy" menu for a table cell?
(1 answer)
Closed 6 years ago.
How to show popup "copy" when select cell of table ?
You can't do it the normal way with UILabel. If you still want to do it, use UITextField instead and disable editing (It will act as label and allow text selection). If you want to use UILabel anyways, you might want to look into UILongGestureRecognizer and UIPasteBoard. Add gesture to the label and on its delegate method, copy text to paste board.

Accessing information from a cell in a new UItableView (Swift) [duplicate]

This question already has answers here:
Find the indexPath of a button inside UITableViewCell when button pressed?
(6 answers)
Closed 6 years ago.
I have a table view which has cells in it. In each cell there is a button to take you to a new UITableView. I am trying to figure out how to get the index of the cell I clicked the button in from the new UITableView because depending on what cell index I choose it needs to show different items in the new UITableView it takes you to. Any help would be appreciated.
set tag property of the button equal to the indexPath.row in cellForRowAtIndexPath method or in your custom cell class if you are using one.
Hence, when its clicked, you can get the value of indexPath.row from its tag (sender.tag).
Note: Assuming there is only one section in your tableview and you wont be inserting or deleting rows runtime. You will have to reload the table in such scenarios.
The best solution that I personally use is, to pass the cell a model object via property or custom method. And later, use the object to make further decisions.

TableView like Contact app with photo [duplicate]

This question already has an answer here:
TableView like the Contacts app in the iPhone
(1 answer)
Closed 9 years ago.
How can i make a tableview like the contacts app,
the main problem is how to place correctly the photoHolder like this :
I give you suggestion that actual UITableView should be Start at 'Telephone' and remain cell such like 'nome', 'Sobrenome' and 'Usuaroi' and also 'photo' taken BOX its all are create on custom UIView.
After Custom view is created then create your UITableView Wich Have groped style and it all customize by UILabel and UITextField.
Interesting.
Never tried such a thing.
If it is really a table ...
I'd try a custom cell for the first 3 cells of which I'd try to change the frame. (Move to the right and make it smaller. But code it in a flexible way. No constants. Use offsets from the right and left margin of the table view.
Then I'd try accessing the table view itself, which in the end is not much more than a subclass of UIScrollView and add a UIImageView as subview exactly there where the photo goes.
Give it a try and have fun ...
Another suggestion:
The first section of the grouped table, the one with the photograph to the left, is not the first section of the table. It is the table header view.
This table header view contains of an UIImage view and a UIcontrainer view. That UIContainer view has a table in it. That scroll view's property is set to not scrollable.
May not be the best idea but looking at the design, it coud work.
Just ... I am not sure how that top left table reponds to scrolling gestures. Touches (selections etc) should work fine.

TableView editing style

I've got a tableView with entries which the user should be able to edit. The special thing is, the tableView has a "right detail" style (a number) and I want this right detail to be replaced (animated if possible) with the standard disclosure indicator accessory, when the user hits edit.
How can I do this? Thank you!
Update: Thank you for the answers so far but could you maybe give me a code example for the part where the number gets replaced by the picture? Thank you!
You can make use of the UITableViewDelegate methods for editing such as tableView:willBeginEditingRowAtIndexPath: to perform your changes. Use cellForRowAtIndexPath: to get the UITableViewCell object.
You can use a custom cell here and do all those works. Here you can use the same cell and add a subview to that cell where you want that change to happen. Later depending on the state i.e; isEditing = True/ false you can display what you want.

Resources