我有一个奇怪的问题,我找不到解决方案(或类似的东西)。 事情是,我的UITableView填充初始信息(用于测试),但无论我做什么,我似乎都不能将它放到分组样式中(我可以在UI上选择它,但它不会显示)TableView委派,填充但不会组
我最初启动了一个TabBar项目,并在选项卡中添加了第三个navigationController视图。
#import <UIKit/UIKit.h>
@interface RootViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
NSMutableArray *tableData;
}
@property (nonatomic, retain) NSMutableArray *tableData;
-(void)initTableData;
@end
这是标题,正如你所看到的,它没有什么特别之处。下面的代码是我刚刚发布标题的.m文件内(只生病张贴注释掉的代码:
@synthesize tableData;
-(void)initTableData
{
tableData = [[NSMutableArray alloc] init];
[tableData addObject:@"Cidade"];
[tableData addObject:@"Veículo"];
[tableData addObject:@"Ano"];
[tableData addObject:@"Valor"];
[tableData addObject:@"Cor"];
[tableData addObject:@"Combustível"];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Busca";
UIBarButtonItem *_backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleDone target:nil action:nil];
self.navigationItem.backBarButtonItem = _backButton;
[self initTableData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return 6;
}
// Customize the appearance of table view cells.
- (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];
}
// Configure the cell...
cell.textLabel.text = [tableData objectAtIndex:[indexPath row]];
return cell;
}
- (void)dealloc {
[tableData release];
[super dealloc];
}
没有什么不寻常的一次,你可以看到... 任何的可能是什么想法造成这个?我试着
- (id)initWithStyle:(UITableViewStyle)style {
// Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
self = [super initWithStyle:UITableViewStyleGrouped];
if (self) {
// Custom initialization.
}
return self;
}
,因为我不知道自己还能做些什么。(也没有工作) 再说,我有设定为File`s业主的委托和数据源。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Set the tab bar controller as the window's root view controller and display.
self.window.rootViewController = self.tabBarController;
RootViewController *rvc = [[RootViewController alloc] initWithStyle: UITableViewStyleGrouped];
[self.window makeKeyAndVisible];
return YES;
}
也许在同一张纸条上,我看起来似乎不会在点击表格后推动视图。 – Erakk 2012-04-17 12:54:37