Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Duke Leto

macrumors regular
Original poster
Mar 17, 2008
166
0
I am making an iPhone application and I know that you can edit the information. (press the edit button, every table view is different , then click on one and voila a keyboard/picker/whatever comes up for you to input data). What do I need to be able to do this. What kinds of classes and functions do I need, and what do they need to be able to do?

Thank you in advance for helping.
 

iphoneGuy

macrumors member
I am making an iPhone application and I know that you can edit the information. (press the edit button, every table view is different , then click on one and voila a keyboard/picker/whatever comes up for you to input data). What do I need to be able to do this. What kinds of classes and functions do I need, and what do they need to be able to do?

Thank you in advance for helping.

Check out the UI Sampes and the other samples they are very good..
 

Littleodie914

macrumors 68000
Jun 9, 2004
1,813
8
Rochester, NY
There are lots of different way to implement a "edit" function.

Do you want to hit the edit button, then click on one of your TableView's rows and have it pull up an edit window for the object in that row?

Or are you looking for a way to place editable text fields into a table view?
 

Duke Leto

macrumors regular
Original poster
Mar 17, 2008
166
0
I would want it to be that when you press the edit button you ca then edit the data in each text field. I recently downloaded the SQLite Books sample code, and I am trying to sift out what I need to know, but if I could get some help here, it would push me forward! :)
 

Duke Leto

macrumors regular
Original poster
Mar 17, 2008
166
0
I have watched the tutorial on making the edit button that goes into editMode. I have realized a bit better how this works. My new question here is how would I go about adding cells or editing text in a text field... not that much different of a question I realize, but I do not want this thread to drown unanswered.
 

Littleodie914

macrumors 68000
Jun 9, 2004
1,813
8
Rochester, NY
I have watched the tutorial on making the edit button that goes into editMode. I have realized a bit better how this works. My new question here is how would I go about adding cells or editing text in a text field... not that much different of a question I realize, but I do not want this thread to drown unanswered.
Could you be a bit more specific? To edit text in a textfield, you can usually just use the setText: method.

To add a cell to a table view, (I assume this is how you mean it) you just need to implement the delegate method:

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

And return a cell that includes the data you want to display. A good place to start is like so:

Code:
UISimpleTableViewCell *cell = [[[UISimpleTableViewCell alloc] initWithFrame:CGRectZero] autorelease];

cell.text = @"Howdy!";
return cell;
 

lucasgladding

macrumors 6502
Feb 16, 2007
319
1
Waterloo, Ontario
I'm still not sure how much detail I want to get into on the forum with the NDA in effect, but here is how I approached editable text fields.

- use custom UITableViewCell with a UITextField as a subview
- override UITableViewCell setSelected: to call makeFirstResponder on the UITextField
- use the view controller viewDidAppear and viewDidDismiss to get the strings from the UITextFields

This is a somewhat different approach than the SQL example, but it works very well for me and requires very little work to implement. That said, I got a few ideas from the example that really helped.

BTW: Offhand, I think you only need the data source methods of UITableView to get the editing functionality.
 

Littleodie914

macrumors 68000
Jun 9, 2004
1,813
8
Rochester, NY
I'm still not sure how much detail I want to get into on the forum with the NDA in effect, but here is how I approached editable text fields.

- use custom UITableViewCell with a UITextField as a subview
- override UITableViewCell setSelected: to call makeFirstResponder on the UITextField
- use the view controller viewDidAppear and viewDidDismiss to get the strings from the UITextFields

This is a somewhat different approach than the SQL example, but it works very well for me and requires very little work to implement. That said, I got a few ideas from the example that really helped.

BTW: Offhand, I think you only need the data source methods of UITableView to get the editing functionality.
Yea, I think that method should also work. For my cells, I did the following:

- use custom UITableViewCell with a UITextField as a subview (like you)
- override UITableViewCell willSelectRowAtIndexPath (or something like that) and return -1, so that the actual cell will never be selected
- make sure that the textfield's bounds are the bounds of the tableviewcell, so that any touch on the cell begins the editing for the textfield

Then, I just maintain a reference to the textfield, and use [textField text] to get the value that the user typed in.
 

Duke Leto

macrumors regular
Original poster
Mar 17, 2008
166
0
Thank You! I just wanted an idea of what I needed to do, and I think that gave me a push! Now a skill I need to work on is properly phrasing questions. I seem to have trouble putting things into words.
 

maxjg

macrumors member
Aug 6, 2006
92
0
Yeah, I'd certainly look at UIShowcase for this. They've got pretty much everything you'll need there.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.