2011-07-22 12 views
1

ボタン付きビューがあります。私がボタンを押すと、uisplitviewが表示されるはずです。問題は、tableview(splitviewのleft = master view)の場合です。詳細ビュー(右)が正しく表示されます。 cellForRowAtIndexPathが呼び出されないため、左は空です。 私の.hファイルにはUISplitViewControllerを拡張し、.mファイルののviewDidLoadに私はこれを実行します。UITableViewデリゲートメソッドがuiSplitViewのマスタービュー用に呼び出されていません

Left *l = [[Left alloc] initWithNibName:@"Left" bundle:nil]; 
Right *d = [[Right alloc] initWithNibName:@"Right" bundle:nil]; 
// Update the split view controller's view controllers array. 
NSArray *viewControllers = [[NSArray alloc] initWithObjects:l, d, nil]; 
self.viewControllers = viewControllers; 
[viewControllers release]; 

マイleft.h:

@interface Left : UIViewController <UITableViewDataSource, UITableViewDelegate> { 

NSMutableArray *tableData; 
UITableView *table; 
} 

@property (nonatomic, retain) NSMutableArray *tableData; 
@property (nonatomic, retain) IBOutlet UITableView *table; 

マイleft.m:

#import "Left.h" 


    @implementation Left 

    @synthesize tableData,table; 

    - (id)initWithStyle:(UITableViewStyle)style 
    { 
self = [super initWithStyle:style]; 
if (self) { 
    // Custom initialization 
} 
return self; 
} 

- (void)dealloc 
{ 
[super dealloc]; 
} 

- (void)didReceiveMemoryWarning 
{ 
// Releases the view if it doesn't have a superview. 
[super didReceiveMemoryWarning]; 

// Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 

[super viewDidLoad]; 
table = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain]; 
table.delegate = self; 
table.dataSource = self; 

table.autoresizesSubviews = YES; 
tableData=[[NSMutableArray alloc] initWithObjects:@"bazinga",@"buzz", nil]; 

//NSLog(@"velikost : %d", [tableData count]); 
[self.view addSubview:table]; 
} 

- (void)viewDidUnload 
{ 
[super viewDidUnload]; 
// Release any retained subviews of the main view. 
// e.g. self.myOutlet = nil; 
} 


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
    { 

// Return the number of sections. 
return 0; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 

// Return the number of rows in the section. 
NSLog(@"size: %d", [tableData count]); 
return [tableData count]; 
    } 

- (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; 
} 


    } 

    @end 

をマスタービューの表にデータを入力するにはどうすればよいですか?

答えて

0

uはしている私は自分で呼び出すために使用されてきたbecuase

self.table = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain]; 

にこの

table = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain]; 

を交換するには、uは、テーブルを合成してきています。

だから私たちはこのようにしなければならない

関連する問題