Access a viewControllers View
        Posted  
        
            by iFloh
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by iFloh
        
        
        
        Published on 2010-04-01T10:13:27Z
        Indexed on 
            2010/04/01
            10:23 UTC
        
        
        Read the original article
        Hit count: 175
        
Hi, I am trying to get to grips with programmatically configuring views. I have a UIViewController and want to add a UIButton to its view.
Well, I created the button:
UIButton *newViewButton = [[UIButton alloc] initWithFrame:CGRectMake(baseX + viewPlusX, baseY + viewPlusY, viewWidth, viewHeight)];
[newViewButton setTitle:@"View" forState:UIControlStateNormal];
[newViewButton setTag:(int)key];
[newViewButton addTarget:myViewController action:@selector(viewButton:sender) forControlEvents:UIControlEventTouchUpInside];
but when trying to add it to the view
[myViewController addSubview:newViewButton];
I get the error
error: expected ':' before":" token
any clue what I am doing wrong
regards
© Stack Overflow or respective owner