iphone - Memory Leak issue in UIPage Control -


- (void)loadscrollviewwithpage:(int)page {     if (page < 0)     return;     if (page > knumberofpages)     return;  if([searchresultarray count]>6) {     if([searchresultarray count]%6==0)     {         knumberofpages = [searchresultarray count]/6;     }     else {         knumberofpages = [searchresultarray count]/6;         knumberofpages = knumberofpages +1;     }      pagecontrol.numberofpages = knumberofpages;     scrollview.contentsize = cgsizemake(scrollview.frame.size.width *knumberofpages, scrollview.frame.size.height); } else {     knumberofpages = 1;     pagecontrol.numberofpages = knumberofpages; }  int z=-1; int = 0;  for(uiview *subview in [scrollview subviews])  {     [subview removefromsuperview]; }  for(int x = 0; x < [searchresultarray count];x++) {        if(x>=6 && x%6==0)     {         z=0;         = a+320;     }     else {         z++;         //a++;     }      uibutton *profileimagebutton = [[uibutton alloc] initwithframe:cgrectmake(a+8+(100*(x%3))+(x%3)*3,15+(110*(z/3))+(z/3)*10, 100, 85)];     [profileimagebutton setbackgroundcolor:[uicolor clearcolor]];     [profileimagebutton setclearscontextbeforedrawing:yes];     [profileimagebutton settag:x];     [profileimagebutton setuserinteractionenabled:yes];     nsstring *imagepath =[nsstring stringwithformat:@"%@",[[searchresultarray objectatindex:x]valueforkey:@"photo"]];     [profileimagebutton setimagewithurl:[nsurl urlwithstring:imagepath]                            placeholderimage:[uiimage imagenamed:@"transparent@2x.png"]];     [profileimagebutton addtarget:self action:@selector(profileimageclicked:) forcontrolevents:uicontroleventtouchupinside];     [scrollview addsubview:profileimagebutton];     [profileimagebutton release];     profileimagebutton = nil;       uilabel *groupnamelabel = [[uilabel alloc] initwithframe:cgrectmake(a+8+(100*(x%3))+(x%3)*3,100+(110*(z/3))+(z/3)*10, 100, 25)];     [groupnamelabel setbackgroundcolor:[uicolor clearcolor]];     [groupnamelabel settext:[nsstring stringwithformat:@"%@,%@,%@",[[searchresultarray objectatindex:x] valueforkey:@"username"],[[searchresultarray objectatindex:x] valueforkey:@"age"],[[searchresultarray objectatindex:x] valueforkey:@"gender"]]];     [groupnamelabel setuserinteractionenabled:yes];     [groupnamelabel setfont:[uifont systemfontofsize:15.0f]];     [groupnamelabel settextcolor:[uicolor whitecolor]];     [scrollview addsubview:groupnamelabel];     [groupnamelabel release];     groupnamelabel = nil; }    

}

- (void)scrollviewdidscroll:(uiscrollview *)sender {  if (pagecontrolused)     {     return; }  cgfloat pagewidth = scrollview.frame.size.width; int page = floor((scrollview.contentoffset.x - pagewidth / 2) / pagewidth) + 1; pagecontrol.currentpage = page;   [self loadscrollviewwithpage:page - 1]; [self loadscrollviewwithpage:page]; [self loadscrollviewwithpage:page + 1]; }  - (void)scrollviewwillbegindragging:(uiscrollview *)scrollview { pagecontrolused = no; }  - (void)scrollviewdidenddecelerating:(uiscrollview *)scrollview { pagecontrolused = no; }  - (void)changepage:(id)sender { int page = pagecontrol.currentpage;  [self loadscrollviewwithpage:page - 1]; [self loadscrollviewwithpage:page]; [self loadscrollviewwithpage:page + 1];  // update scroll view appropriate page cgrect frame = scrollview.frame; frame.origin.x = frame.size.width * page; frame.origin.y = 0; [scrollview scrollrecttovisible:frame animated:yes];  pagecontrolused = yes; } 

i working on app in retrieving images server , images shown on uipagecontrol, though have done this.but on on scrolling pagecontrol many times shows memory leak warning , app exits

on console

received memory warning. program received signal: “0”. data formatters temporarily unavailable, re-try after 'continue'. (unknown error loading shared library "/developer/usr/lib/libxcodedebuggersupport.dylib")


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -