Warning: UIView may not respond to '-view'

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

  1. AbhishekApple macrumors member

    Aug 5, 2010
    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..

    @synthesize detailView;
    - (void)viewDidLoad {
        [super viewDidLoad];
    	//detailView = [[UIView alloc] init];
    	detailView.frame = CGRectMake(230, 140, 538, 820);
    	[self.view addSubview:detailView];     
            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..
    @interface ThumbDetailView : UIView{
    @implementation ThumbDetailView
    	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

    Jun 22, 2010
    'self' is-a UIView already, so 'self.view' does not make any sense.

    [self addSubview:lblprodNm]

Share This Page