newTextField working on simulator but not on iOS7

Hi,

I have an app that uses a text field to gather information. The app worked on until the last couple of days where I updated my test device to iOS7.

I am updating the app to version 2.0, and the textfield works on the simulator but not on the device. The app version 1.0 that is on the app store does not work either on iOS7 where it works on iOS6.

SDK has changes since the first version of my app but to simplify I have tried changing the textfield function to as follows:

local serialNumField; local function fieldHandler2( event ) print("Text entered: ".. event.target.text) if event.phase == "began" then print("begin") -- user begins editing textField elseif event.phase == "ended" then print("ended") -- textField/Box loses focus elseif event.phase == "submitted" then print("submitted") -- do something with defaulField's text native.setKeyboardFocus( nil ) elseif event.phase == "editing" then print("editing") end end --serialNumField.userInput = fieldHandler2; serialNumField:addEventListener ("userInput", fieldHandler2)

On the simulator I see printed in console the first “Text entered:” with the correct text I have entered afterwards but in the device I get it without the text entered.

I also do not see any print on any of the phases where I used to see them before iOS7, looks like it does not detect them.

Am I doing something wrong or is it a iOS bug?

Thanks for the help in advance!

What version of Corona are you building with?

I’m building with last one 1210.

Just to clarify, the app version I have now on the app store built like months ago, was working before iOS7 with latest iOS6 version but does not work now either (same way as the latest version I am building with latest build). I can see the textfield, and the keyboard appears but when i tap the keyboard no characters seem to be grabbed at all.

I’ll try with the interface sample code from latest build to see what happens, but will have to wait until tomorrow morning when I get to the office (midnight now here).

That’s a good idea.  I have an app published pre-iOS 7 with text fields and they still work after the device got updated to iOS 7.  

[quote name=“JonPM” post=“206217” timestamp=“1379975554”]That’s a good idea.  I have an app published pre-iOS 7 with text fields and they still work after the device got updated to iOS 7.  [/quote] We’ll that’s good news! I am relieved now I just need to find out what I am doing wrong

Hey, I have similar issue. Using 2013.1202, I get input on simulator on OSX but not on the iPad 2 running iOS7. Just blinking cursor, no detection of input in my fieldHandler. Tried this with console and got this:

Sep 24 12:17:45 Jyrkis-iPad kbd[169] \<Warning\>: -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](754): CoreData: Ubiquity: &nbsp;mobile~74D149EF-A5D4-532E-B4AB-AD3650B3B44D:UserDictionary &nbsp;&nbsp;&nbsp;&nbsp;Using local storage: 1 Sep 24 12:17:46 Jyrkis-iPad kbd[169] \<Warning\>: -[PFUbiquitySetupAssistant canReadFromUbiquityRootLocation:](1350): CoreData: Ubiquity: &nbsp;Error attempting to read ubiquity root url: file:///private/var/mobile/Library/Mobile%20Documents/com~apple~TextInput/Dictionaries/. &nbsp;&nbsp;&nbsp;&nbsp;Error: Error Domain=NSCocoaErrorDomain Code=134323 "The operation couldn’t be completed. (Cocoa error 134323.)" UserInfo=0x17561ef0 {NSAffectedObjectsErrorKey=\<PFUbiquityLocation: 0x17574f90\>: /var/mobile/Library/Mobile Documents/com~apple~TextInput} &nbsp;&nbsp;&nbsp;&nbsp;userInfo: { &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;NSAffectedObjectsErrorKey = "\<PFUbiquityLocation: 0x17574f90\>: /var/mobile/Library/Mobile Documents/com~apple~TextInput"; &nbsp;&nbsp;&nbsp;&nbsp;} Sep 24 12:17:46 Jyrkis-iPad kbd[169] \<Warning\>: -[PFUbiquitySetupAssistant finishSetupWithRetry:](811): CoreData: Ubiquity: &nbsp;\<PFUbiquitySetupAssistant: 0x1762b9e0\>: Retrying after delay: 60 &nbsp;

I do have “userInput” event handler bound to the field, and the event.phase==“editing” part seems to cause troubles. Other fields are working though. Any ideas?

Hi,

Well I tried the sample code for Native Keyboard and works fine, so there must be something wrong in my code interferring there.

This is the full code of the textfield:

local serialNumField local function serialNumFieldDelayCreation( event ) serialNumField = native.newTextField( \_W\*0.5 - 90, searchCodeGroup.y+FindLotText.y+FindLotText.height+12, 180, 30 ) serialNumField.font = native.newFont( "HelveticaNeue-Light", 14 ) serialNumField.align = "center" serialNumField.hasBackground = false; local function fieldHandler3( textField ) print("entered fieldHandler3") return function( event ) if ( "began" == event.phase ) then print("began") elseif ( "ended" == event.phase ) then currentSerialNumberEntered=myfunctions.trim(serialNumField.text) elseif ( "editing" == event.phase ) then print( "editing newtext: "..serialNumField.text.." - "..event.target.text.." - "..textField().text ) serialNumField.text =string.upper(serialNumField.text) elseif ( "submitted" == event.phase ) then print( "submitted newtext: "..serialNumField.text.." - "..event.target.text.." - "..textField().text ) currentSerialNumberEntered=myfunctions.trim(serialNumField.text) -- Hide keyboard native.setKeyboardFocus( nil ) end end end serialNumField:addEventListener( "userInput", fieldHandler3( function() return serialNumField end ) ) end --Adding delay to not interfere with other layers, giving them time to hide timer.performWithDelay(500, serialNumFieldDelayCreation )

When I run the app in the simulator I see the prints while editing with al the three possible ways to gather the text entered filled in correctly.

So for instance if I write “Hello”, i see printed

“editing newtext: HELLo - HELLo - HELLo”

Last character not yet in upper case.

But When I run the app on the device I do not see anything appear on the textfield and in console in Xcode I get:

“editing newtext: - -”

I keep troubleshooting see what I can find :frowning:

LOL funny part,

Tested on the device using the speech to text from the keyboard and the result got inserted into the field and printed in the console during the editing phase, but the keyboard is not responding I cannot edit nor delete the text in the textfield

UPDATE: I just read Tom’s post in the iOS7 Beta Build that the native.textField editing issue was fixed. Just tried the 6.1 build on a iOS 7 device and this appears to be fixed - at least for my situation. Thanks Corona team!

I have a similar situation where I intercept keys for the textfield. I found the textfield to work fine on both ios7 and ios6 devices when built for ios7 but unfortunately we can’t build for distribution yet. Who knows how long we have to wait!

The previous ios6 build does not work on an ios7 device. Strange but true.

Hello,

I have an issue regarding text fields too after updating my device to iOS7. I’m glad your issue got fixed, but here’s what’s wrong with mine:

The text field intercepts my input as double. For instance, if I enter the number “4” in my text field, the print statement in the simulator terminal shows “4”, however the device console shows “44”. This happens randomly, as in sometimes it’s repeated, sometimes it’s not.

I know for a fact it’s not my code because pre-iOS7 this worked fine, plus the fact that the simulator log is showing the correct entered value, while the device log is showing a repeated value. I’m using the “number” keyboard input.

To further check, I ran the Native Keyboard sample code and added a print statement in the “editing” phase. To my surprise, instead of it getting repeated, it actually started delaying the output. For instance, while typing “Test”, nothing appeared until I entered the “s”.

So to sum up, the text fields are cranky. Can anyone else please confirm this or give a possible fix?

P.S: I’m running iOS7 on iPhone4 and using build 1210.

I’m working with engineering to look into this. 

Hi Rob, thanks for the interest.

I finally managed to fix my code. I copied my code into the keyboard interface sample code, and built it several times until I made it work.

I had to move the declaration of the fieldHandler function to the top of the lua file before the “function scene:createScene( event )” of the storyboard code, and now it detects the keyboard.

I believe serialNumField.text = string.upper(serialNumField.text) is causing this glitch. I’m having the same problem when I’m trying to limit the number of characters. I’m testing on an iPhone 5 with iOS7 using build 1170 still. (I installed build 1210 to try to fix this problem specifically, which it didn’t work on this one as well).

Any help on how to limit characters for iOS 7 would be grateful.

@RedPistonEB, you are going to have to use 1217 or later to work past all iOS 7 keyboard related issues.

Hey Rob, thanks for the update, the new build is working fine for me.

Good to hear!

This explains alot I have spent the last week making a work around thought I had it all working and now found another bug.  When might this fix make it to the public release?

It won’t make it until the next public build, which will be after Graphics 2.0 is reasonably solid.  It’s in Alpha testing now.

That is surprising as this seems like a big issue to anybody using the public builds with text input on IOS 7. Maybe I am overreacting but I had to stop selling one of apps because input is a big part of it.  Luckily I have a pro account and access to daily builds and was able to get an update for the issue. As a platform that is trying distinguish itself for apps that are not just games it seems very surprising course of action. Again not trying to stir up much, just trying to get a feel for the platform future and support as my pro renewal date looms next year. 

Thanks!

Ya my pro account expired and its gone up in price this year I was just going to get the ios only option since I dont bother with Android apps anymore.  At least I know that a daily build fixes it.  Maybe thats how you sell pro accounts.  If I had know there was a fix it would have saved me a week of re writing around the bug only to find another strange bug the first character entered disappears  on device only.