Get the name of the current iPhone xib being viewed
I have 3 xib files connected to the same class to reduce duplicate coding. However, there are different stuff that I want done when the new nib file loads (i.e. in the ViewDidLoad method). I've thought about doing an if statement to compare the name of the xib currently being displayed to a string. I have been trying to figure out how to do that for most of the day but I haven't ha开发者_运维问答d any luck. Here's some pseudo code if that confused you:
if (currentXibInDisplay == @"XibFileName1")
// Do This...
else if (currentXibInDisplay == @"XibFileName2")
// Do This...
There is a way to do that, right? It seems pretty simple but I am pretty stumped right now. Thanks for any info you can provide.
I tried to use it with
self.view.nibName;
But it won't work, instead try this
self.nibName;
You can use the nibname
if you say: NSString *name = self.view.nibname
you can proove it with
`[name isEqual:@"XIBName"]`
The view controller that you're loading has the initWithNibNamed:
method, you can override there and store which XIB is going to be loaded.
ViewController subclasses have a nibName string property you can check against:
[self.nibName isEqualTo:@"XIBFileName"]
精彩评论