IBAction does nothing. Logs “Back” to console so the connection’s OK. self.topView also does nothing when the IBAction is called
-(IBAction)loadSettingsView:(id)sender;
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
[[NSBundle mainBundle] loadNibNamed:@"settingsView_iphone" owner:self options:nil];
} else {
[[NSBundle mainBundle] loadNibNamed:@"settingsView_ipad" owner:self options:nil];
}
[self.view addSubview:topView];
}
-(IBAction)loadMainView:(id)sender;
{
[topView removeFromSuperview];
NSLog(@"back");
}
I hope I am not making too many assumptions here, but this should solve your problem. I am assuming
topViewis a member of the current class:Basically, the
loadNibNamedmethod you are using is returning an array with all the top-level views in the nib. If you want a reference to these views (And here I am assuming there is one view in the nib), you need to actually assign yourtopViewvariable. CurrentlytopViewis probably nil, so yourremoveFromSuperviewcall is doing nothing.