Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

TableView crashes on focus in text field in header or footer view with empty table

I have table view headers and footers with text fields.

If the table view is empty, the app crashes when the text field gets focus.

The following error sometimes appears in the developer log:

[ERROR] Value was not the value expected. in -[TiUITableView keyboardDidShowAtHeight:forView:] (TiUITableView.m:1745)

I'm going to try working around this by adding a dummy row when the table would otherwise be empty.

This is in the iphone emulator with the 4.1 iphone sdk and the 1.4.2
Titanium sdk.

Here's a sample app that demonstrates this:


  var title_view = Ti.UI.createView({height: '30'});
  title_view.add(
      Ti.UI.createTextField(
          { height:20, borderStyle:Ti.UI.INPUT_BORDERSTYLE_BEZEL}));

  var items_view = Ti.UI.createTableView(
      {top: 0, data: [], footerView: title_view});
  var win = Ti.UI.createWindow({title: 'Win2'});
  win.add(items_view);
  win.open();

When the window opens, click in the text field. It doesn't crash
every time. I may have to re-launch the app a few times to see the
crash.

— asked December 1st 2010 by Jim Fulton
  • tableview
3 Comments
  • i'm experiencing this same issue!

    — commented January 21st 2011 by Kevin Southworth
  • Is there a fix for this issue?

    I did try doing the following code below to get rid of the error. However, this causes the screen to shift down and moves the text field in the center when the text field gains focus i.e. when you click on the text field.

    It's very strange. Does anyone have any ideas?

      var empty;
      empty.push({empty:''});
    
      var title_view = Ti.UI.createView({height: '30'});
      title_view.add(
          Ti.UI.createTextField(
              { height:20, borderStyle:Ti.UI.INPUT_BORDERSTYLE_BEZEL}));
    
      var items_view = Ti.UI.createTableView(
          {top: 0, data: [], footerView: title_view});
      var win = Ti.UI.createWindow({title: 'Win2'});
      win.add(items_view);
      win.open();
      win.open();
    
    — commented March 20th 2011 by Dennis Lo
  • Sorry the code above was wrong.
    I forgot to add the 'empty' array as the data property.

    I've corrected it below.

    Still it's not what I want as it just gets rid of the error but produces some strange behavior.

      var empty;
      empty.push({empty:''});
    
      var title_view = Ti.UI.createView({height: '30'});
      title_view.add(
          Ti.UI.createTextField(
              { height:20, borderStyle:Ti.UI.INPUT_BORDERSTYLE_BEZEL}));
    
      var items_view = Ti.UI.createTableView(
          {top: 0, data: empty, footerView: title_view});
      var win = Ti.UI.createWindow({title: 'Win2'});
      win.add(items_view);
      win.open();
      win.open();
    
    — commented March 20th 2011 by Dennis Lo

3 Answers

  • Jim

    I'm afraid without some code I doubt there is much anyone can add to this.

    The best way for you to obtain a resolution is by creating the simplest code (remove any superflous properties and functionality), that runs without modification when someone pastes it into an empty app.js script. If you provide this, someone will assist you.

    — answered December 1st 2010 by Paul Dowsett
    permalink
    1 Comment
    • Fair enough.

      I've updated the question with the code.

      — commented December 1st 2010 by Jim Fulton
  • I have the exactly same problem. Any fixes out there yet?

    — answered June 23rd 2011 by Felix Krause
    permalink
    0 Comments
  • I can confirm this problem. Currently the only way around it is to make sure the tableview is never empty. I set data = [{title:''}] anytime the table needs to be empty and make sure to blur the keyboard before replacing the data array. A fix would re really nice!

    — answered June 28th 2011 by Chris Roemmich
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.