2010-03-03 3 views

Répondre

5
  1. Nouveau fichier (Cocoa Touch Class -> sous-classe UIViewController) de sous-classe UITableViewController, avec XIB pour l'interface (vérifiez les deux)
  2. fichier Xib ouvert
  3. le changement du style de vue (Plain-> groupe) sur les attributs inspecteur (touche pomme + 1)
  4. add code suivant dans le fichier .m
 
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 
 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return 2; 
} 
 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
     cell.selectionStyle = UITableViewCellSelectionStyleNone; 
    } 

    if(indexPath.row == 0) { 
     cell.textLabel.text = @"Username"; 
     UITextField *field = [[[UITextField alloc] initWithFrame: CGRectMake(120, 10, 180, 30)] autorelease]; 
     [cell addSubview:field]; 

    } 
    else if(indexPath.row == 1) { 
     cell.textLabel.text = @"Password"; 
     UITextField *field = [[[UITextField alloc] initWithFrame: CGRectMake(120, 10, 180, 30)] autorelease]; 
     field.secureTextEntry = YES; 
     [cell addSubview:field]; 
    } 

    return cell; 
} 
 
- (NSString *)tableView: (UITableView *)tableView 
titleForHeaderInSection: (NSInteger)section 
{ 
    return @"Account"; 
} 
 
- (NSString *)tableView: (UITableView *)tableView 
titleForFooterInSection: (NSInteger)section 
{ 
    return @"If you don't have a twitter account, go to twitter.com to sign up."; 
} 
+0

Incroyable! Je vous remercie! –