Can I make a cell be in editing mode all the time? - iphone

I have a UITableView with one section. The last row it to add new objects, and it reads "Add Object".
How can I make this cell stay in editing mode so that it will always show the plus icon? I've tried using cell.editing = YES and [cell setEditing:YES animated:NO] but neither makes the cell appear in editing mode.
Thanks!

Implement delegate's
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
method. You might also need to set tableview's editing property to YES, but I am not sure.

Related

Overriding the default tableview setEditing behaviour

I have currently implemented the setEditing/commitEditing methods for my table view, which now shows the 'delete' button upon swiping a cell.
Just wondering if there is any way to change the text on this button from 'delete' to something else, so that I can use the 'commitEditing' method to perform custom behaviour, such as update some settings?
thanks
You can specify the delete button title with the UITableViewDelegate method:
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath

UITableView Delete button

I want to replace the default delete buttons in editing style of UITableView with my own buttons. how to do it?
-(NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:
(NSIndexPath *)indexPath
{
return #"title!";
}
this edits title of button .What about changing the color of button..
can anyone help me out
We can customize the default delete button in UITableView.But as per the IOS Human Interface guidelines your app may rejected by the apple if ur try to change that one.
You can refer http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/Introduction/Introduction.html

Delete Button in UITableView

i want a Delete Button in my UITableView like in die AdressBook when editing a contact.
Is this a custom cell, or a UIButton?
To make such button you can do following:
Make your UITableView style Grouped.
Add +1 section to your table.
Say to your table that it is one cell for last section
Just return custom cell (with red background and appropriate label) for last section
If you implement the Delegate method's for edit the tableview
- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
And than implement the DataSource method
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
For allowing to get that delete button when you swipe a cell use the
Cell Editing Style : UITableViewCellEditingStyleDelete
// Edit: Wrong answer.
Do you mean the Big one at the bottom or with the sign on the left?
use....
firstly use
[btn removeFromSuperview];
and
[tblobj reload];

How to display the selected cell in highlighted state when i come back in UITableView?

I created a custom cell for my table view and for the most part everything seems to be working fine, but when I select one of the rows (which takes me to another UIView), then come back from the subsequent view via the nav controller, the selected cell is not in highlighted state. How to display the selected cell in highlighted state when i come back?
any help is appreciated in advance, thanks.
when you are coming back from anotherview make sure that save the selectedCell and then in viewwillappear method reloaddata.in cellforindexpath write the code of selection style uitableviewcellselectionstyleblue
As #sachin said, you should save selected index path
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
self.selectedIndexPath = indexPath;
}
and in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
You should check if indexPath is equal to selectedIndexPath,
but you should be aware that Apple discoureges that kind of behavior in HIG: http://developer.apple.com/library/ios/#DOCUMENTATION/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html
In rare cases, a row might remain highlighted when secondary details
or controls related to the row item are displayed in the same screen.
However, this is not encouraged because it is difficult to display
simultaneously a list of choices, a selected item, and related details
or controls without creating an uncomfortably crowded layout.

How to preselect a certain section in a newly generated UITableView

I have a UITableView that I build up programmatically and want to preselect a certain section header at startup.
Any hints how I can achieve that?
I'm not quite sure what you mean by pre-select a section header. If you're looking to ensure that the section you are interested in is visible when your app starts you can use this method on UITableView:
- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath
atScrollPosition:(UITableViewScrollPosition)scrollPosition
animated:(BOOL)animated
If you want to select a row in a particular section you could use this method (which will also scroll to the selected row):
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath
animated:(BOOL)animated
scrollPosition:(UITableViewScrollPosition)scrollPosition