iphone - Custom control doesn't display in window -


i'v created view based application. , added new class extends uiview. class contains controls in (simple controls). want display/hide control when user click on something. control should displayed overlay window. on other controls. try like:

- (void)viewdidload {     [super viewdidload];             addsubview:myoverlaychannelpicker; } 

everything goes fine, debug in custom control code nothing display on screen. tried add manually , works, need add in runtime. reason not displaying control?

complete code overlaychannelpicker

@implementation overlaychannelpicker @synthesize myimage; @synthesize img1; @synthesize img2;  - (id)initwithframe:(cgrect)frame {     if ((self = [super initwithframe:frame])) {         // initialization code     }     return self; }  - (void)awakefromnib{     img1 = [uiimage imagenamed:@"imgtest.jpg"];     img2 = [uiimage imagenamed:@"imgtest2.jpg"];      arrayofimages = [[nsmutablearray alloc] init];     [arrayofimages addobject:img1];     [arrayofimages addobject:img2];     [arrayofimages addobject:img1];     [arrayofimages addobject:img2];     [arrayofimages addobject:img1];     [arrayofimages addobject:img2];     [arrayofimages addobject:img1];     [arrayofimages addobject:img2];     [arrayofimages addobject:img1];     [arrayofimages addobject:img2];     [arrayofimages addobject:img1];     [arrayofimages addobject:img2];      scrollview = [[uiscrollview alloc] init];     scrollview.scrollenabled = yes;     scrollview.pagingenabled = no; // smooth scroll     scrollview.directionallockenabled = yes;     scrollview.showsverticalscrollindicator = no;     scrollview.showshorizontalscrollindicator = no;     scrollview.delegate = self;     //scrollview.backgroundcolor = [uicolor bluecolor];     scrollview.autoresizessubviews = yes;     scrollview.frame = cgrectmake(0, 150, 320, 128);     [scrollview setcontentsize:cgsizemake(1620, 128)];     [self addsubview:scrollview];      uiimage *imagetoadd;     int x = 0;     int y = 0;     for(imagetoadd in arrayofimages)     {                uiimageview *temp = [[uiimageview alloc] initwithimage:imagetoadd];               temp.frame = cgrectmake(x, y, 128, 128);         temp.userinteractionenabled = yes;               x += 135;           uitapgesturerecognizer *tap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(imagetapped:)];         [temp addgesturerecognizer:tap];              [scrollview addsubview:temp];     }  }  - (void)imagetapped:(uigesturerecognizer *)sender {            uiimageview *iv = (uiimageview *)[sender view];     uiimage *image = [iv image];     uiimage *it = [arrayofimages indexofobject:image];      [uiview beginanimations:nil context:null];     [uiview setanimationduration:1];     [uiview setanimationtransition:uiviewanimationtransitionflipfromleft forview:iv cache:yes];      if(it == img1)         = img2;     else         = img1;      [uiview commitanimations];   } 

and it's header:

@interface overlaychannelpicker : uiview <uiscrollviewdelegate>{     iboutlet uiimageview *myimage;     uiimage *img1;     uiimage *img2;        iboutlet uiscrollview *scrollview;     int view1index;     int view2index;      nsmutablearray *arrayofimages;  } @property (nonatomic, retain) uiimageview *myimage; @property (nonatomic, retain) uiimage *img1; @property (nonatomic, retain) uiimage *img2; @property (nonatomic, retain) uiscrollview *scrollview;  - (void)awakefromnib; @end 

you want make call this:

[self.view addsubview:myoverlaychannelpicker]; 

by of posted code sample have assume have not been doing objective-c development before. if case should start here introduction objective-c programming language basics covered.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -