2011-11-14 12 views
3

をクリックしたとき、私は、受信トレイ]ボタンをクリックしたときのUITableViewで私の電子メールのヘッダを表示したい、私の電子メールヘッダーがNSMutableアレイ、NSMutableのUITableViewに配列ボタンが

-(IBAction)buttonInbox:(id)sender{ 

     NSLog(@"Inbox Button Clicked %@",buttonInbox); 
     [self select:@"INBOX"]; 
     NSArray *lines = [self sendCommand:@"fetch 1:* (body[header.fields (from subject date)])"]; 



     //NSMutableArray *emaiArray= [[NSMutableArray alloc] init]; 
     NSMutableString *totalEmail= [NSMutableString stringWithString:@""]; 

     int counter = 0; 
     int i =0; 
     NSRange tmp; 
     for(i=0;i<[lines count];i++) 
     { 

      NSString *line = [lines objectAtIndex:i]; 

      //NSLog(@" Burda %@" ,line); 
      tmp = [line rangeOfString:@"Date:"]; 
      if(tmp.location != NSNotFound) 
      { 
       //NSLog(@" Date basildi %@" ,line); 
       counter++; 
       [totalEmail appendString:line ]; 

      } 

      tmp = [line rangeOfString:@"From:"]; 
      if (tmp.location != NSNotFound) { 
       //NSLog(@" From basildi %@" ,line); 
       counter++; 
       [totalEmail appendString:line ]; 
      } 

      tmp = [line rangeOfString:@"Subject:"]; 
      if (tmp.location != NSNotFound) { 
       //NSLog(@" Subject basildi %@" ,line); 
       counter++; 
       [totalEmail appendString:line ]; 
      } 
      if (counter==3) { 
       [emailList addObject:totalEmail]; 
       counter =0; 
       NSLog(@"total Email %@" ,totalEmail); 
       totalEmail = [NSMutableString stringWithString:@""]; 
      } 
    } 
} 

に保存されている私は、これまでのところ、これを試みたが、couldntのきそれはとにかく

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return [emailList count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"Cell %i",indexPath.section]]; 

    if (cell == nil) { 

     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:[NSString stringWithFormat:@"Cell %i",indexPath.section]] autorelease]; 

    } 

    cell.textLabel.text = [emailList objectAtIndex: indexPath.row]; 

    return cell; 
} 

答えて

2

buttonInbox:セレクタの最後に[[self tableView] reloadData]を呼び出してみ空のテーブルビューを表示ボタンがイベントをクリックしたときに、これは、このdoesntのはどのように動作置くために任意のガイドラインを見つけます。

これにより、tableViewが更新されます。

私は、しかし、あなたがより良いビジュアル体験を取得し、テーブルビューが入ってくるの行をアニメーションさせることができますのUITableViewのドキュメントを見て示唆して-(void) beginUpdates-(void) endUpdatesを使用する方法を見るであろう。

+0

このdidntのは働いています私のテーブルビューは** UITableView * mytableView; ** ** @ property(非構造、保持)IBOutlet UITableView * mytableView; **のように宣言していますので、私の.mファイル内のmytableviewメソッドは使用しないでください。 –

+0

私はそれを理解する、私はテーブルビューのファイル所有者に代理人をドラッグするのを忘れた –

関連する問題