iphone - Hide ImageView when it is visible -


i have button display scrollview. have 3 images under awesomeview. added awesomeview scrollview scrolling. when click image awesomeview add myimageview8. because myimageview8 display awesomeview images center of screen. need hide myimageview8 or awesomeview when visible in screen

code:

scroll = [[uiscrollview alloc] initwithframe:cgrectmake(0, 420, self.view.frame.size.width, self.view.frame.size.height)]; scroll.pagingenabled = yes; nsinteger numberofviews = 3; (int = 0; < numberofviews; i++) {     //  cgfloat xorigin = * self.view.frame.size.width;     // awesomeview = [[uiview alloc] initwithframe:cgrectmake(xorigin, 0, self.view.frame.size.width, self.view.frame.size.height)];      awesomeview = [[uiview alloc] initwithframe:cgrectmake(0, 0, 320, self.view.frame.size.height)];      awesomeview.backgroundcolor=[uicolor clearcolor];     [scroll addsubview:awesomeview];      img = [uibutton buttonwithtype:uibuttontypecustom];      [img setimage:[uiimage imagenamed:@"img.png"] forstate:uicontrolstatenormal];     // [overlaybutton setframe:cgrectmake(80, 420, 60, 30)];      [img setframe:cgrectmake(0, 0, 100,130)];      [img addtarget:self action:@selector(img:) forcontrolevents:uicontroleventtouchupinside];     [img settag:0];      [awesomeview addsubview:img];      img1 = [uibutton buttonwithtype:uibuttontypecustom];     [img1 setimage:[uiimage imagenamed:@"sofa_s2.png"] forstate:uicontrolstatenormal];     // [overlaybutton setframe:cgrectmake(80, 420, 60, 30)];     [img1 setframe:cgrectmake(110, 0, 100,130)];     [img1 settag:1];      [img1 addtarget:self action:@selector(img1:) forcontrolevents:uicontroleventtouchupinside];     [awesomeview addsubview:img1];      img2 = [uibutton buttonwithtype:uibuttontypecustom];     [img2 setimage:[uiimage imagenamed:@"sofa_s3.png"] forstate:uicontrolstatenormal];     // [overlaybutton setframe:cgrectmake(80, 420, 60, 30)];      [img2 setframe:cgrectmake(210, 0, 100,130)];     [img2 settag:2];     [img2 addtarget:self action:@selector(img2:) forcontrolevents:uicontroleventtouchupinside];     [awesomeview addsubview:img2]; } scroll.contentsize = cgsizemake(self.view.frame.size.width * numberofviews, self.view.frame.size.height); [self.view addsubview:scroll]; 

myimageview8 display awesome center of screen:

myimageview8=[[uiimageview alloc]initwithframe:cgrectmake(0, 50, 320, self.view.frame.size.height)]; [self.view addsubview:myimageview8]; myimageview8.userinteractionenabled=yes;  -(void)img:(id)sender {     if(myimageview8){         [myimageview8 removefromsuperview];     }      else {         [myimageview8 addsubview:awesomeview];     } }  -(void)img1:(id)sender {     if(myimageview8) {         [myimageview8 removefromsuperview];     }     else {         [myimageview8 addsubview:awesomeview];     } }  -(void)img2:(id)sender {     if(myimageview8) {         [myimageview8 removefromsuperview];     }     else {     [myimageview8 addsubview:awesomeview];     } } 

if click button scroll displaying. when click image, if myimageview8 visible reappearing.

enter image description here


Comments