Warning: UIView may not respond to '-view'

Discussion in 'iOS Programming' started by AbhishekApple, Dec 8, 2010.

  1. AbhishekApple macrumors member

    Joined:
    Aug 5, 2010
    #1
    I have created two views (mainView & detailView) in IB.... and have added the detailView as subview to mainView....

    Now when i want to add subviews to detailView it is not allowing to do so..& gives a build error..

    Code:
    @synthesize detailView;
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    	//detailView = [[UIView alloc] init];
    	detailView.frame = CGRectMake(230, 140, 538, 820);
    	[self.view addSubview:detailView];     
    }
    -(void)createsubview{
            slideUpView = [[UIView alloc] initWithFrame:frame];
         [COLOR="DarkOrange"]   [[detail view] addSubview:slideUpView]; [/COLOR] //----warning : UIView may not respond to '-view'
          //following works fine 
           //[[self.view] addSubview:slideUpView];  
    }
    
    Also when i am creating custom class UIView, same error is given..
    Code:
    @interface ThumbDetailView : UIView{
    ....
    ....
    }
    
    @implementation ThumbDetailView
    
    -(id)initWithFrame:(CGRect)_frame{
    	self=[super initWithFrame:_frame];
    	if (self) {
    		[self setUserInteractionEnabled:YES];
    		[self setExclusiveTouch:YES];
    	}
    	return self;
    }
    -(void)createView:(NSString *)_prodCode{
    	
    	[COLOR="DarkOrange"]CGRect bounds = [[self view] bounds];  [/COLOR]  // warning---- ThumbDetailView may not respond to '-view'
            // add subviews to container view
    	[[COLOR="SandyBrown"]self.view [/COLOR]addSubview:lblprodNm]; // warning---- ThumbDetailView may not respond to '-view'
    }
    
    Plz suggest how to add subView to existing subview
     
  2. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #2
    'self' is-a UIView already, so 'self.view' does not make any sense.

    Code:
    [self addSubview:lblprodNm]
     

Share This Page