I have a view controller and it has connected via xib. In that xib I have a seperate view and I connected this same view to 2 different IBoutlets and added this view to main view. But in the outlet the view which I added second is only visible. The first one is not able to see. Why?
Share
Although it is possible to connect two outlets to the same view object, it is rarely advisable to doing so. In your case this is only one UIView (subclassed) object. Both IBOutlet ‘pointers’ refer to the same (individual) object.
If you now setup both, first and then the second, layout them etc. then you will have the impression that only the second one is visible. That is what you are saying.
Lets assume you have layouted your left view first and your right view second then it appears to you that only the right view is visible.
If you now turn around the secuence of layouting statements (what ever that ist, position, size, frame, colour, …) and layout the right view and then the left view, only the left view will appear. This is simply because you managed to link the same object to two IBOutlets. By layouting the second one you simply overwrite the layout data that you set in the first hand.
From what I read between the lines in your case I would suggest to create (probably duplicate) an additional UIView (or whatever subclass) in IB and link them accordingly to one IBOutlet each.