how to create a cell view which has a button and a "shorter cell" like contacts app? - iphone

I haved tried to create a view with a UIButton and a tableView Cell,
then I set the header view to be this view.
However,the cell in the header is not rounded-rect, besides,how to handle the cell's event,when user click this cell.
I haved tried to use custom cell also, but how to create a button and a shorter cell in a row?
when you select the cell,will not affect the button state?
thanks.

You can fake this in a number of ways. The simplest is to layout a rounded rectangle UIButton in your header, and turn off userInteraction for it so that it's just decorative.

Related

How to show custom options on swipe table cell in a simple way

I am working on a app which includes table cells. I want that when i swipe table cell it shows two options, first about that cell value and another for delete that value. How can i show that in a way that the cell value shows in half of cell and the options show in half of cell.
Thanks in advance.
There are an out of the box solution, called HHPanningTableViewCell. It does exactly what you need!
HHPanningTableViewCell is a UITableViewCell implementing "swipe to reveal" a drawer view. Such a view typically holds action buttons applying to the current row.
This library, SWTableViewCell, should help you:
https://github.com/CEWendel/SWTableViewCell
An easy-to-use UITableViewCell subclass that implements a swipeable content view which exposes utility buttons (similar to iOS 7 Mail Application)
You have to create a custom cell and override Apple's behavior which is swipe left to delete and then show your options. You can add gesture recognizer to the cell and on swipe to left animate the cell content view and animate in your option view or however you like it to be. I can write up an example code if you need.

How do I tell the difference between the user tapping my table view cell and the user tapping a subview contained within the cell?

One of my view controllers contains a UITableView with custom UITableViewCell's. My custom UITableView cell contains a UIImageView subview that represents a tappable icon. When the user taps anywhere on the custom cell, except the icon subview, I want my didSelectRowAtIndexPath method to be called like normal. But when my icon subview gets tapped, I want a different method to get called, but I can't figure out how to do this. Do I have capture the touch position in the touchesDidBegin method and manually check if the user tapped the icon? That just feels so hacky. Other, cleaner ideas?
Thanks so much for your wisdom!
Simply add a tapGestureRecognizer to the UIImageView in your cell

UITableViewCell subclass - how to add a button to some rows

I have a UITableViewCell subclass that has 3 labels and sizes and positions the labels based on the text length. When selected all rows perform the same function. I'd like some rows to also have a detail view associated with them. So I want to add a UIButton to a few rows, but I'm not sure how to do it.
Should I create a UIButton member of the UITVCell subclass and in layoutSubviews if the button is not nil I can make room for it?
What would cellForRowAtIndexPath look like? Do I need two reuse identifiers ? One for button and one for no button? Or just create the button and the cells that have buttons will automatically detect the button in layoutSubviews and make room for it?
I can't find any examples online of someone doing this without using XIB..
EDIT - So I added the detail disclosure button as suggested below, I can detect that my cell has an accessoryType, but the accessoryView width and height are garbage.. I need a width and height because right now the accessory is on Top of my row text since I'm not accounting for it in my layoutSubviews code..
// CustomTableViewCell.m:
- (void)layoutSubviews {
// I need a width / height here so I can accomodate the accessory button.
if ( self.accessoryType != UITableViewCellAccessoryNone ) {
NSLog(#"accessory! %f %f",self.accessoryView.frame.size.width, self.accessoryView.frame.size.height);
}
}
You don't need to add a UIButton to rows that have a detail view -- just allow them to have a disclosure button (note: button, not indicator!). A disclosure button, when tapped, typically shows a detail view for that cell.
To enable the disclosure button for a certain cell, do the following in the cellForRowAtIndexPath method:
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
More details here:
What's the difference between an Detail Disclosure Button and an Disclosure Indicator?

Allow input in a UITableViewCell

So I have a UITableView (its in a UIPopOverController if that matters), and I want the user to be able to edit the content of the tableView. I added a UINaviagationController, the tableView also has a title and an edit button. Essentially what I'm asking is, when the user taps the edit button, how can I add like UITextViews to some of the tableViews and in one of the cells, a UISegmentControl and a UITextView.
Thanks in advance
just add them as subviews of the cell, set correct frame to make subviews inside the cell

Adding a button in the bottom of a TableView

I'm trying to add a button on the bottom of a TableView, without any success.
The idea isn't to use the tableFooterView property, as that doesn't show the button in a fixed position.
My idea is more along the lines of the Facebook application's Notifications bar on the bottom.
I'm using Three20.
Any pointers on how I can achieve this?
Thanks
Just add button to the view below your tableview but ensure your table height is less than the position you are adding the button,this way your can scroll table above button & your button will always be visible
Just embed custom view over your tableview.i mean on the bottom of tableview.so the tableview will scroll and the view don't.
Add a UIView as the footerView and then add the UIButton to the UIView.