Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Kapthehat

macrumors member
Original poster
Jul 1, 2013
51
0
Hello

I am getting a "no visible interface for UIView" on the last line in my code (underlined). can anybody explain why ? thanks

Kaps

Code:
//
//  BIDSwitchViewController.m
//  view Switcher
//
//  Created by Kapil Kapur on 21/08/2013.
//  Copyright (c) 2013 Apress. All rights reserved.
//

#import "BIDSwitchViewController.h"
#import "BIDYellowViewController.h"
#import "BIDBlueViewController.h"

@interface BIDSwitchViewController ()

@end

@implementation BIDSwitchViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.blueViewController = [[BIDBlueViewController alloc]
                               initWithNibName:@"BlueView" bundle: nil];
    [self.view insertSubview:self.blueViewController.view atIndex:0];
    
    
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    
    if (self.blueViewController.view.superview == nil)
    {
        self.blueViewController =nil;
    }
    else
    {
        self.yellowViewController=nil;
        
        
    }
}


-(IBAction)switchViews:(id)sender
{
    if (self.yellowViewController.view.superview == nil)
        
    {
        if (self.yellowViewController== nil)
        {
            self.yellowViewController = [[BIDYellowViewController alloc] initWithNibName:@"YellowView" bundle:nil];
        }
        
        
        [self.blueViewController.view removeFromSuperview];
        [self.view insertSubview:self.yellowViewController.view atIndex:0];
        
        
    }
    else
    {
     if (self.blueViewController==nil)
     {
         self.blueViewController = [[BIDBlueViewController alloc] initWithNibName:@"BlueView" bundle:nil];
         
     }
        [self.yellowViewController.view removeFromSuperview];
        [U][B][self.view insertSubView:self.blueViewController.view atIndex:0];
[/B][/U]        
        
    }
        
        
}
@end
 

Guiyon

macrumors 6502a
Mar 19, 2008
771
4
Cambridge, MA
insertSubView:atIndex: is not a valid UIView method. You have subtle error in that line of code. Recheck the documentation; the error should stick right out.
 
Last edited:

Kapthehat

macrumors member
Original poster
Jul 1, 2013
51
0
Thanks. I re-entered the line and it worked. However when I ran it I get a message saying that the view outlet was not set. I have checked and there is a connection from the File's Owner to the view - so I am a bit confused.

Can somebody help ? thanks

regards

Kaps
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,544
6,042
Without your Xcode project, it's rather difficult to help you find out why your connections aren't working.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.