• After more than 15 years covering everything Apple, it’s with a heavy heart we announce that we will no longer be publishing new content on iMore and the iMore forums will be closing as of November 1st, 2024.

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

Latest posts

Trending Posts

Members online

Forum statistics

Threads
262,097
Messages
1,774,352
Members
441,394
Latest member
Blin