ios - Prevent UITableViewCells from creating as you scroll down -


i'm creating mail screen using visually resembles ios native email app. looks (both images of same screen. first 1 top half , second 1 rest of it).

enter image description here

enter image description here

the difference mail screen has more custom fields in addition normal to, cc, subjet fields.

i'm using uitableviewcontroller create this. below code snippet creates cell (for each cell it's pretty same).

- (uitableviewcell *)tokentableview:(titokentableviewcontroller *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {      uitableviewcell *cell = nil;     self.tableview.frame = cgrectmake(0,0,320,320);     uiview *contentsubview = nil;      cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifiersubject];         if(!self.txtsubject) {              self.txtsubject = [[uitextfield alloc] initwithframe:cgrectmake(0, 0, 0, 0)];             self.txtsubject.frame = cgrectmake(10, cell.frame.size.height / 2 - self.txtsubject.font.lineheight / 2, tableview.tableview.bounds.size.width, 30);              self.txtsubject.placeholder = @"subject";             [self setupmaildata:indexpath.row];         }     contentsubview = self.txtsubject; } 

say, open draft. details in input fields filled , without changing anything, hit send , crashes app. know what's causing this. problem cells under viewable portion of screen gets created scroll down, right? in scenario, if send without scrolling down cells below viewport don't exist throws error.

if open draft, scroll down , hit send, works fine.

i need know if there's way create these cells @ once. cells below viewport @ first. not depending on user scroll down.

i hope have idea situation. can suggest solution?

thank you.

follow steps:

  1. take uiscrollview , set scrollview frame want display.
  2. take uitableview subview of uiscrollview
  3. set property scrolling enabled = no (uncheck checkbox in .xib) of uitableview
  4. call reloaddata method of uitableview
  5. set tableview frame , contentsize of scrollview

    tblemail.frame = cgrectmake(yourxpos, yourypos, yourwidth, tblemail.contentsize.height); scrollobj.contentsize = cgsizemake(yourscrollwidth,tblemail.contentsize.height+10); 

so, height of tableview equal contentsize. so, create cells @ time. , set contentsize of scrollview equal tableview contentsize. so, scrolling feature worked uitableview scrolling...


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -