UA-17470720-3

Jump to content


Photo
- - - - -

STV 4.05 UI Customization in Interface Builder - Curly Brace Binding

data-definitions cells sections view-controllers bug

  • Please log in to reply
6 replies to this topic

#1 jet21

jet21

    Jr. Member

  • STV 4.0 Std
  • PipPip
  • 18 posts
Reputation: 0
Neutral

Posted 15 December 2014 - 03:41 PM

Hello,

 

I'm currently customizing a cell in IB(STV 4.05), using curly brace binding for a parse data definition date field. The date column in Parse is set to type: date. I'm using date picker to select date in IB - date formatter: MMM d  y.

 

When I run the program, my date in my detail view shows as: May 5 2015, which is similar to how my data field for "date" is saved in Parse: May, 5, 2015, 23:21

 

However, my date on my customized cell - utilizing curly brace binding: {date} - shows as : 2015-05-15 23:21:10 +0000. Is this a bug?

 

Ideally, I would my date field format on my custom cell to display as: May 5, and continue to display as May 5 2015 on my detail view.

 

How can I get my date field format on my custom (curly brace binding ) cell to display as  /Month / Year/ (May 5) or /Month/ Day/ Year/ (May 5 2015) as it displays on my detail view?

 

Thanks....



#2 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 15 December 2014 - 04:10 PM

i think you do it like

Attached File  Screen Shot 2014-12-16 at 10.08.26 am.png   112.83K   23 downloads

 

have a look in the samples folder for the Parse sample app


Edited by ozie, 15 December 2014 - 04:11 PM.

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#3 jet21

jet21

    Jr. Member

  • STV 4.0 Std
  • PipPip
  • 18 posts
Reputation: 0
Neutral

Posted 15 December 2014 - 04:49 PM

My first sentence conveys my parse setting. It's set properly. Apparently you don't understand my question/issue with curly brace binding.



#4 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 15 December 2014 - 04:54 PM

no need to be an ass


P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#5 jet21

jet21

    Jr. Member

  • STV 4.0 Std
  • PipPip
  • 18 posts
Reputation: 0
Neutral

Posted 15 December 2014 - 05:08 PM

no need to be an ass

Not being one. Have a look at video in order to understand my question: 



#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 16 December 2014 - 09:53 AM

Hi jet21, ozie,

 

Take it easy guys, Ozie was just trying to help :)

 

jet21: Yes this turns out to be a curly brace binding bug. STV should take the date formatting from the date property definition (the image Ozie posted), but apparently it doesn't. If you need an urgent fix until we ship our next release, please do the following:

 

1. From IB, select your date label and assign a tag to it (let's say 100).

 

2. Manually set the date label value from code as follows:

 

// MasterViewController.m
- (void)viewDidLoad {
    [super viewDidLoad];
    
    SCArrayOfObjectsSection *objectsSection = (SCArrayOfObjectsSection *)[self.tableViewModel sectionAtIndex:0];
    objectsSection.cellActions.willDisplay = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
    {
        NSDate *dateValue = [cell.boundObject valueForKey:@"date"];
        UILabel *dateLabel = (UILabel *)[cell.contentView viewWithTag:100];
        
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"MMM d  hh:mm a"];  // or any format you wish
        
        dateLabel.text = [dateFormatter stringFromDate:dateValue];
    };
}

 

Hope this helps.


  • wizgod likes this

#7 jet21

jet21

    Jr. Member

  • STV 4.0 Std
  • PipPip
  • 18 posts
Reputation: 0
Neutral

Posted 16 December 2014 - 10:41 AM

Hi jet21, ozie,

 

Take it easy guys, Ozie was just trying to help :)

 

jet21: Yes this turns out to be a curly brace binding bug. STV should take the date formatting from the date property definition (the image Ozie posted), but apparently it doesn't. If you need an urgent fix until we ship our next release, please do the following:

 

1. From IB, select your date label and assign a tag to it (let's say 100).

 

2. Manually set the date label value from code as follows:

 

// MasterViewController.m
- (void)viewDidLoad {
    [super viewDidLoad];
    
    SCArrayOfObjectsSection *objectsSection = (SCArrayOfObjectsSection *)[self.tableViewModel sectionAtIndex:0];
    objectsSection.cellActions.willDisplay = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
    {
        NSDate *dateValue = [cell.boundObject valueForKey:@"date"];
        UILabel *dateLabel = (UILabel *)[cell.contentView viewWithTag:100];
        
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"MMM d  hh:mm a"];  // or any format you wish
        
        dateLabel.text = [dateFormatter stringFromDate:dateValue];
    };
}

 

Hope this helps.

Thanks, Tarek!  :) I'll use your urgent fix until next release. 







Also tagged with one or more of these keywords: data-definitions, cells, sections, view-controllers, bug

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users