How to customize the Delete button shown when swipe a UITableViewCell - ios

I have a table view and enabled the swipe to delete feature by providing an empty implementation of - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath of the table view controller.
I can see a red 'Delete' button when I swipe left the table cells.
But the button's label is 'Delete' despite that the system locale is not English.
I have too problems.
1. I want the Delete button to be localized according to the locale.
2. I want to add some other button, like that in the Podcast app of Apple.

there is too much solutions... you should to search before posting new question. check this link:
iOS Programming 101: How To Create Swipeable Table View Cell to Display More Options
or use ready-made solutions like this:
https://github.com/CEWendel/SWTableViewCell
i can't post much links without 10 reputation, so try to google "custom delete button uitableviewcell"

Related

Edit UITableViewCell inline in same view controller

I have a table view controller where I show a shopping bag (or shopping cart). In each cell I show an image view, an a few labels with some information. One of those labels shows the quantity of products for that product. I want that when I press the edit button the quantity label becomes a stepper (or something like that) where I can change the quantity. I have seen that behavior on other apps (specific on Zara for iPhone, a clothes store) but I cannot figure out how to do that. All I have found on the internet is to segue to another view where you can edit an item, but that's not what I want to do.
How is it possible to implement such a behavior?
Thanks a lot!
You can try to add the stepper on the label, in the UITableView Method,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
This method allows you to perform actions when a table view cell is selected.

Can I use both UITableViewCellEditingStyleInsert and UITableViewCellEditingStyleDelete two button together?

I return canEditRowAtIndexPath is YES. If I swipe left, I can see the delete button and implement my delete action. How can I do if I swipe left, both insert button and delete button appear together?
I know there is a way, I should have a custom cell with two button on the right and just add a panGesture to recognize the swipe action. But I want to use Apple provide for us to do such easy work. Just can see insert and delete button together when I swipe the cell left? My apology for my poor expression.
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(editingStyle==UITableViewCellEditingStyleInsert)
{
NSLog(#"click insert");//I only have delete button, I also want to have insert button .
}
if(editingStyle==UITableViewCellEditingStyleDelete)
{
NSLog(#"click delete");
}
}
I know tableView:editActionsForRowAtIndexPath can do this job … But it is provide for IOS8.0 and later,,How to do for IOS7
At least as of iOS 8 this can't be done (I don't know if this changed in iOS 9). A cell can only have one of the 3 possible editing styles - None, Insert, or Delete. UITableViewCell does not support both Insert and Delete at the same time. When the table is in editing mode, the cell will show either no button, an insert icon on the left, or the delete icon on the left based on the row's single editing style.
It actually makes no sense to have both insert and delete on the same row. What does that mean for the user? Normally a table view would only have a single row (per section) that might have the insert editing style. This row, when tapped, allows the user to add a new row to the table view. Other existing rows might have the delete editing style to allow the user to delete that specific row.
So again, what would it mean for a single row to have both insert and delete editing styles?

Button Displays Under Cells in Custom UITableViewCell

I have an app that uses a custom UITableViewCell to display detail information after a user clicks on a given row in a table. I can't seem to figure out why the "Reply" button located in the cell is inactive and appears behind the table itself. I can't click on it, select it, or do anything. I used Interface Builder to add the button rather than programmatically add it.
I've tried changing a number of things including the cell's class and File's Owner, but can't seem to get the button to be active and working. I think the button is linked up properly with a connection to a method in the code.
Here's a minimal, complete example of the code:
https://www.dropbox.com/s/atcof58ciqbaojr/CustomCell.zip
Apparently I needed to tell the table view how high the cell was. This is what fixed it:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
return 157.0;
}

iOS - How to display the same table view after selecting an item

My iOS app is current transferring control to a detail view when an item in a UITableView is selected. This ia a quiz program, and I'd like to change the app so that it just redisplays the same table view with the correct answer highlighted when a row is selected. What's a good approach for doing this?
Is not clear to me if you know why the detail view is appearing. So I'll explain just in case. If you are giving control to a detail view is because somewhere in your code you are pushing that detail view. It depends on what kind of UITableViewCell you are using. If you are using one of the defaults styles, your detail view is probably been pushed in either:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
or
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
If you are using a custom cell, then you need to look for the method in charge of pushing
that detail view.
I think a good approach would be to:
Remove that pushing wherever it is.
Not to use an `UITableViewCellAccessoryType, if you are using one.
Do something similar to the following on your tableView:didSelectRowAtIndexPath:
Find the row for the right answer in your model array, according to tapped cell.
Use that row number to generate an NSIndexPath.
Use that NSIndexPath to find the correct cell with cellForRowAtIndexPath:
Call setSelected:animated: on that cell to highlight it.
NOTE: If your quiz has more answers than the amount of UITableViewCells that fit in the screen you should scroll your UITableView to the right answer for better UX.

What's the difference between a Detail Disclosure Button and a Disclosure Indicator?

What's the difference between a Detail Disclosure Button and a Disclosure Indicator?
For me, both things are the exact same thing, just that they look a little bit different. The first is a blue round button with an chevron to the right. The second is an simple chevron to the right. Both things mean the same, to me. They mean "more". But someone claimed that Apple will reject the app if the one or the other is used in the wrong situation.
Does someone have an example when the blue Detail Disclosure Button is used, and when the simple Disclosure Indicator one is used?
From Apple's iPhone Human Interface Guidelines (a must-read if doing iPhone development):
Disclosure indicator. When this element is present, users know they
can tap anywhere in the row to see the
next level in the hierarchy or the
choices associated with the list item.
Use a disclosure indicator in a row
when selecting the row results in the
display of another list. Don’t use a
disclosure indicator to reveal
detailed information about the list
item; instead, use a detail disclosure
button for this purpose.
Detail disclosure button. Users tap this element to see detailed
information about the list item. (Note
that you can use this element in views
other than table views, to reveal
additional details about something;
see “Detail Disclosure Buttons” for
more information.) In a table view,
use a detail disclosure button in a
row to display details about the list
item. Note that the detail disclosure
button, unlike the disclosure
indicator, can perform an action that
is separate from the selection of the
row. For example, in Phone Favorites,
tapping the row initiates a call to
the contact; tapping the detail
disclosure button in the row reveals
more information about the contact.
Once you use the detail disclosure button it acts like a button.
Meaning that the user has to tap this button in order to perform some action (you can catch this tap by implementing the - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath method of the UITableViewDelegate).
If you use the indicator then it just draws the arrow on the right and you will have to implement the - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath in order to catch the tap on the entire table cell.
Hope it helps...

Resources