0

WORKGROUND

Create a UIView with UILabel and UIButton. Here i have set layer properties of UIButton below:

[self.btnDropdown.layer setBorderColor:[UIColor lightGrayColor].CGColor];
[self.btnDropdown.layer setBorderWidth:0.8f];
[self.btnDropdown.layer setCornerRadius:4.0f];

Now i am saving this custom view into file using NSCoding and load the same. This control is displayed in UITableViewCell.

ISSUE:

All the details of custom view like UILable title, size, background color etc. Same for the UIButton are retrieved from file. But CALayer related details which i have set for UIButton are not retrieved.

Before saving to file:

enter image description here

After getting from file:

enter image description here

So I am not clear about that CALayer properties are manage with UIButton object.

Is these details (CALAyer values) are visible only at run time? Or i am missing something?

Please add a comment if question is unclear to you.

EDIT:

Previously i have not provide more information to reduce the complexity of the question. Below is complete hierarchy of my implementation.

NSObject --> Custom View --> UIButton --> CALayer

1) First NSObject class is a bean class. Which contains some variables (i called it Property). This properties are meta details of Custom view. There is one variable "parentView" is use to store Custom view.

2) Custom view: This is UIView class which contains UILabel and UIButton

Now bean class object (Property) is stored in file and retried. So that i can use variable parentView to load Custom view.

And as per question about the UIButton is embedded in that Custom view.

Kampai
  • 22,848
  • 21
  • 95
  • 95
  • Please check the result of this method `- (BOOL)shouldArchiveValueForKey:(NSString *)key` for the layer of your custom view. The key name will be `borderColor` etc. before archiving your custom view – devluv Aug 27 '14 at 09:08
  • @croyneaus4u: Tried that, no change :( – Kampai Aug 27 '14 at 11:07
  • Can you please show me what you have tried ? – devluv Aug 27 '14 at 11:40

1 Answers1

0

Figure it out:

Here button shown in images custom views. I used to save these control in local database with BLOB.

Thing is that these views object/instance are stored in database with some properties.

Now when i retrieve them and add them to any view as a subview their -init method is not getting called. (Any how i figure that out) and called -init method for these views.

Kampai
  • 22,848
  • 21
  • 95
  • 95