Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS who is file owner of subview?
    primarykey
    data
    text
    <p>I am newbie in iOS development and I have a problem to understand file owner logic.</p> <p>I have this situations:</p> <p>I have two views (View_iPad, View_iPhone) and their controllers (ViewController_iPad, ViewController_iPhone). Based on a device where app is launched, particular view and its controller is used. Then, I add a subview from xib file to this view (it doesn't matter if iPad or iPhone view is used). Let's say that there is a different position of this subview in iPad and iPhone view. This subview contains some labels, so I have to create IBOulets in subviews controller.</p> <p>If I understand, according to apple's logic, file owner of view is a controller (file which has access to this view and can communicate with it). So each of 3 views (iPhone, iPad, subview) has its own controller, it means that these controllers are file owners of these views.</p> <p>But when I load subview with code: </p> <pre><code> NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"subview" owner:self options:nil]; </code></pre> <p>and add it as a subview to iPad/iPhone view, there is a problem because this subview contains IBOutlets for labels and this labels are in subview controller and not in a iPhone/iPad controller.</p> <p>This error is shown then:</p> <blockquote> <p>Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[&lt;__NSCFConstantString 0x7ab4> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'</p> </blockquote> <p>How can I solve this? I tried to put as a owner @"subviewController" but it didn't help. Thank you.</p> <p><strong>EDIT!!:</strong> So I was trying to solve this but still it doesn´t work. Here is a new situation:</p> <p>Subview controller is owner of the subview but custom class of the root view is a class (derived from UIView) which contains outlets.</p> <p>If I have in iPad/iPhone controller owner:@"subviewController", Igot this error:</p> <blockquote> <p>Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[&lt;__NSObject 0x715bf30> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'</p> </blockquote> <p>Where the view is a property from subview controller. Now tell me where is the problem. I am really desperate!</p> <p>Or If I have owner:self, some window with instructions is opened with EXC_BAD_ACCESS error.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload