Multiple images on a custom table view cell (Swift) - swift

I'm trying to think of how to best solve this...currently my app supports a user uploading and saving an image to Parse and then retrieving it to a UIImageView on a custom table view cell. However, how would I go about implementing multiple pictures where a user swipes the top picture and the next photo is shown, all in the same table cell? Does this require a new view? If so, how do I do this?
Thanks!

Follow that tutorial that Caleb recommended but you could also use a gesture recognizer on your custom cell. You can design the cell in the storyboard, make a subclass from UITableViewCell and connect the components via outlets to your custom class.

Related

How to add UILabel and UiImageView to a UIView inside table view cell programmatically?

How can we add a label and a imageview inside a u UIView view which is placed inside a uitableviewcell. I want to build a chat screen like whatsapp, in-order to build the screen I want to append the label which is to display the chat messages and image view to the UIView which is placed inside the table view cell.
If you want to do it fully programatically without storyboard you can watch this video for creating custom cells and views.
video by Brian Voong https://www.youtube.com/watch?v=p_ak_ORr3KY&list=PL0dzCUj1L5JE1wErjzEyVqlvx92VN3DL5&index=4
or you can do this using storyboard
I mostly prefer mixing storyboard and code mainly because of adding/editing constraints I find much easier with storyboard.
video by Kilo Loco
https://www.youtube.com/watch?v=Wu5l4e5uW4w

A custom headerView like iPhone contacts image and small UITableViewCell

I am trying to get an application that has UITableview with a custom header view. I want the header view to be quite similar to the iPhone contacts app (see picture) when you are editing/adding a new contact i.e. a small image to the left and 2 to 3 static text entry cells on the right that look like the UITableView Grouped cells.
Whats the easiest way to achieve this design in IB or Code (without Story board)? At the moment it seems like I have to create a Parent UIView, add an image on the left and add a UITableView on the right and populate it with UITableViewCell dynamically. But this seems cumbersome and means I have to implement another class with a UITableView delegate protocol to populate the UITableview cells in the header.
Is there an easier way to do this?

UITableViewCell Swipe for Drawer

This is really more of a curiosity than a hard coding question.
Both Facebook and Twitter both have a feature where swiping a UITableViewCell animates the cell off the side to reveal a drawer with more controls underneath. How is something like that accomplished?
Here is a great open-source method for doing exactly this, based on the behavior of the Twitter app:
https://github.com/thermogl/TISwipeableTableView
This is a problem I have tried a couple of different solutions to. I really liked the behavior of Mailbox (mailboxapp.com). So I set out to achieve this. In the end I ended up with what I believe is a very simple solution: use a UIScrollView inside your cell. I have blog post that discusses and a sample app that demonstrates this behavior.
2 ways to detect swipt action
look at the willTransitionToState: method of UITableViewCell.
this method will be invoked when you swipe at the cell.
Custom swipe detection in a TableViewCell
and then you can change your cell view easily.
You could just implement -tableView:willBeginEditingRowAtIndexPath: in your table view delegate.
From the doc,
This method is called when the user swipes horizontally across a row; ... This method gives the delegate an opportunity to adjust the application's user interface to editing mode.
As a UITableViewCell is just a UIView, you can use this fact to basically do anything you like with it.
To solve your problem, I'd attach a UISwipeGestureRecognizer to detect the swipe and then animate the view to a different state.
For example, you could create a custom cell that has it's content view laying above the "actions view". Whenever there is a swipe, you use a UIView animation to move the content view aside and show the action view with a couple of buttons instead. In a custom UITableViewCell you could add a delegate protocol to have the pressed action and the cell being sent to the delegate, i.e. your controller. There you'd trigger what ever there is to trigger and then transition the cell out of the state.

Multiple images per row in UITableView's cell

Is there any sample code that would illustrate how to have multiple images within each row?
Typical apps show a thumbnail to the left side with text to the right. I'd like to do that plus an image to the right of the text.
How would I go about doing this?
In interface builder, simply create a tableview cell that looks like you want. Then create a UITableViewCell subclass that has properties pointing to the elements of the new cell. Set the class of cell to the subclass then add cells of that class to the table in the standard way.
A tableview cell is just a view and you modify it and use it just like any other view.
You'll have to create a custom UITableView cell. Here's an example of using multiple UILabels in one. Here's another.
Pretty easy - follow Apple's documentation to create exactly the cell you want in Interface Builder with as many UIImage or whatever else you like. Look at Table View Programming Guide for details on how to make and load the custom cells - just be careful about performance when you put a lot of visual elements in a table view.

Edit mode for UITableViewCell using Interface Builder

I converted my old UITableViewCell from being programmatically created to using Interface Builder and a Xib. When implemented in code and in edit mode, I moved some of the labels in the cell to make room for the delete button. How do I change the layout of the cell in edit mode when implemented as a Xib? Preferably animated. Links or tutorials are certainly welcome!
If it matters, this is for a 3.0 SDK app.
You need to get a reference to the subviews you would like to move. Two ways to do this are:
Tag the views in IB
Use IBOutlets
If you tag the subview you would like to move, you can find it by:
[cell.contentView viewWithTag:kMyTag];
If you choose to use IBOutlets, you should consider creating Cell Controllers for each cell.
A good tutorial on this can be found here:
http://bill.dudney.net/roller/objc/entry/uitableview_from_a_nib_file
Also consider moving your cell logic into the cell controllers and out of the table view controller as mentioned in this tutorial:
http://cocoawithlove.com/2008/12/heterogeneous-cells-in.html