Quiero hacer una pregunta sobre el iPhone.solicitud. Estoy escribiendo un programa con UINavigationController, y puedo hacer clic en la celda UITableView e ir a la página de detalles. Sin embargo, no sé cómo crear la siguiente vista de tabla. (Uso el didSelectRowAtIndexPath
para ir a otra página) ¿Cómo puedo crear este tipo de tabla? ¿Igual que el UITableViewController?
texto alt http://www.freeimagehosting.net/image.php?02730817e4.png
enlazar: http://www.freeimagehosting.net/image.php?02730817e4.png
// ---- Actualización -----
El detailViewController.h
#import <UIKit/UIKit.h>
@interface DetailViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> {
UIView *view;
UITableView *tableView;
}
@property (nonatomic, retain) UIView *view;
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, assign) id<UITableViewDataSource> dataSource;
@property (nonatomic, assign) id<UINavigationControllerDelegate> delegate;
@end
DetailViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
CGRect cgRct = CGRectMake(0.0, 0.0, 480, 320);
view = [[UIView alloc] initWithFrame:cgRct];
view.autoresizesSubviews = YES;
self.view = view;
tableView = [[[UITableView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 480.0f, 400.0f) style:UITableViewStyleGrouped] autorelease];
[view addSubview: tableView];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [dataArray count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSString *title = nil;
switch (section) {
case 0:
title = @"First Name";
break;
case 1:
title = @"Middle Name";
break;
case 2:
title = @"Last Name";
break;
default:
break;
}
return title;
}
¿Cómo agregar los datos de la celda pulsada?
Respuestas
3 para la respuesta № 1Es un UITableView estándar con su estilo configurado para UITableViewStyleGrouped
. "Fecha", "Género" y "Caracteres principales" son encabezados de sección; configúrelos con tableView:titleForHeaderInSection:
Método en la fuente de datos.