Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-18-2011, 05:37 AM   #1 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 1,106
Meredi86 is on a distinguished road
Default method call question

Hey all,

I have this textfield method that i am using:
Code:
- (void)textFieldDidEndEditing:(UITextField *)textField;
Fairly straight forward. But it means that for the method to be executed the user needs to move away from the text field. This in my situation can cause some bugs so i need to save the value in the textfield as the user is going rather than at the end of their typing and moving to the next text field.

to do this i have thought of calling the above method on ValueChanged of a textField. But would this work or would it still require the textField to end editing for the contents of the method to be executed?

the method looks like this:
Code:
switch (textField.tag) {
        case 1:
            if(textField != nil)
            {
            self.savedName = textField.text;
            }
            break;
....
The problem with this i have been coming across so far is that i cannot reference to the textfield from anywhere else, even if i am using a property to assign the reference to the field when i create it:

Code:
if ([indexPath section] == 0) {
        UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(25, 7, 285, 35)];
        textField.adjustsFontSizeToFitWidth = YES;
        textField.delegate = self;
        textField.textColor = [UIColor blackColor];
        if ([indexPath section] == 0) { 
            if ([indexPath row] == 0) {
                //textField.delegate = self;
                [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
                textField.placeholder = @"Name";
                textField.keyboardType = UIKeyboardTypeDefault;
                textField.returnKeyType = UIReturnKeyDone;
                textField.tag = 1;
                textField.text = self.savedName;
            }
Meredi86 is offline   Reply With Quote
Old 11-18-2011, 08:57 AM   #2 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

You could do this. Get the indexpath of the cell that contains the textfield you want to get a reference to. Keep in mind, the cell has to be on screen. Then call cellForRowAtIndexPath on your UITableView. You can call viewWithTag on the cell.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 404
18 members and 386 guests
7twenty7, Alex-alex, Apptronics RBC, baja_yu, chiataytuday, dre, e2applets, gwelmarten, ipodphone, jeroenkeij, jleannex55, matador1978, mbadegree, n00b, pbart, QuantumDoja, Retouchable, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:25 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0