私は奇妙な問題を抱えていて、解決策(または同様のもの)を見つけることができませんでした。問題は、私のUITableViewに初期情報(テスト用)が入力されますが、何をしてもグループ化されたスタイルにできないようです(UIで選択できますが、表示されません)
最初にTabBarプロジェクトを開始し、タブに3番目の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`sOwnerに設定しました。
- (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;
}