我有一個奇怪的問題,我找不到解決方案(或類似的東西)。 事情是,我的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