can't displaying UIView

gairp

Member
May 12, 2011
6
0
0
Visit site
i was trying to create simple animation,but something is wrong in my code :(
main UIView :
Code:
@interface TouchResponder : UIView {
    IBOutlet UIView *stalker;    
}
@end
i want to display stalker with code. and i am initializing it in TouchResponder's init ;
Code:
@implementation TouchResponder 
- (id)init
{
    self = [super init];
    if (self) {
        CGRect  viewRect = CGRectMake(10, 10, 100, 100);
        stalker = [[UIView alloc] initWithFrame:viewRect];
        [stalker setCenter:CGPointMake(0,0)];
        [stalker setBackgroundColor:[UIColor blueColor]];
    }
    return self;
}
I only want to display that blue rectangle in my main UIView
 

osmosisapps

New member
May 21, 2011
1
1
0
Visit site
Is the problem that the view doesn't appear?

If so, you might find that you need to implement initWithFrame:(CGRect)frame rather than init, as that is the standard way. If the view is being initialised from a nib file, then you will also need to implement initWithCoder:

Hope this helps.
 
  • Like
Reactions: gairp

Trending Posts

Members online

Forum statistics

Threads
260,379
Messages
1,766,631
Members
441,239
Latest member
smitty22d2