0

I want to show my own custom UIView in storyboard. By far I have done following but my custom view is not showing up.

  1. Dragged and dropped a UIView instance in my screen.
  2. Defined the class for this UIView as my custom class.
  3. Have connected this UIView with an IBOutlet in my view controller.

I even tried with below code in viewWillAppear.

self.myView = [[MyCustomView alloc] initWithFrame:frame];

This works if I create an instance of my custom view and add as a subview to my IBOutlet property for my view. So, below code is working but I want to keep track of only my IBOutlet iVar and do not want to play with another object for changes on my custom view:

self.myExtraView = [[MyCustomView alloc] initWithFrame:frame];
[self.myView addSubview:self.myExtraView];

Any idea how to do this in a better way so that I could have just one reference of my custom view and could change properties on it as per will.

Abhinav
  • 37,684
  • 43
  • 191
  • 309
  • Do you want this custom view to be a subview of the controller's self.view, or do you want it to be the controller's self.view? – rdelmar Sep 11 '13 at 00:31
  • I want it to be the self.myView which is a subview of the view controller. Have got it fixed by implementing intiWithCoder method. – Abhinav Sep 11 '13 at 03:58
  • @Abhinav Which xcode are you using? In latest xcode 5, I have added UIView by drag & drop to storyboard separately, but i did not see that view. How can i see that view? – Sunil Zalavadiya Sep 21 '13 at 10:46
  • @sunilz I am using XCode 5 only. Try by changing the background color of the UIView you dropped in there. By default it should be clear color and may not be visible at run time. If you have any specific question, please raise a question and give me the link. Will be happy to look into it and respond. – Abhinav Sep 21 '13 at 17:51
  • @Abhinav See link of my questions:- http://stackoverflow.com/questions/18931764 – Sunil Zalavadiya Sep 23 '13 at 03:49

1 Answers1

4

Found the issue. With storyboard we must initialize anything in initWithCode method. I was implementing the regular init method.

Abhinav
  • 37,684
  • 43
  • 191
  • 309