iphone - How to release subview in iOS -


this code add subview , want check before adding subview.

numberofviews = [[globalvariable sharedinstance].itemnewsdetail count];   (int = 0; < numberofviews; i++) {     @try{         cgfloat xorigin = * 320;         cgrect frame;         frame.size = cgsizemake(320, 365);         frame.origin.x = xorigin;         frame.origin.y = 0;          detailvc = [[detailscrollvc alloc]initwithnibname:@"detailscrollvc" bundle:nil];         detailvc.view.frame = frame;         [detailvc loadviewbyindex:i];          uifont *font = detailvc.txtbodynews.font;         detailvc.txtbodynews.font = [font fontwithsize:currentfontsize];         detailvc.txtbodynews.tag = i;          [scrolldetail addsubview:detailvc.view];         [scrolldetail sizetofit];         [detailvc.view release];     }@catch (nsexception *exception) {         nslog(@"error handling : %@",exception);     } } 

how check , release subviews add before.

thanks.

if want remove subviews scrollview or other view try code:

 numberofviews = [[globalvariable sharedinstance].itemnewsdetail count];   (uiview *subviewelement in scrolldetail.subviews)   {      [subviewelement removefromsuperview];  }   (int = 0; < numberofviews; i++)  {      @try      {         cgfloat xorigin = * 320;         cgrect frame;         frame.size = cgsizemake(320, 365);         frame.origin.x = xorigin;         frame.origin.y = 0;          detailvc = [[detailscrollvc alloc]initwithnibname:@"detailscrollvc" bundle:nil];         detailvc.view.frame = frame;         [detailvc loadviewbyindex:i];          uifont *font = detailvc.txtbodynews.font;         detailvc.txtbodynews.font = [font fontwithsize:currentfontsize];         detailvc.txtbodynews.tag = i;          [scrolldetail addsubview:detailvc.view];         [scrolldetail sizetofit];         [detailvc release];      }      @catch (nsexception *exception) {         nslog(@"error handling : %@",exception);      }  } 

i hope helps better understanding . thanks


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -