タブバー内でsplitViewControllerを学習しています。5つのタブがあり、そのうち5つ目はsplitViewControllerです。見せることができます。私のMasterViewはDetailsViewにデータを送信します。ただし、DetailViewラベルには表示されません
AppDelegate.m
- (void)showMainMenu:(NSNotification *)notification {
UserListViewController *userlist = [[UserListViewController alloc] init]; //MASTER VIEW
UINavigationController *userListNavController = [[UINavigationController alloc] initWithRootViewController:userlist];
UserDetailsViewController *userDetails = [[UserDetailsViewController alloc] init]; //DETAIL VIEW
UINavigationController *userDetailsNavController = [[UINavigationController alloc] initWithRootViewController:userDetails];
UISplitViewController *splitViewContr = [[UISplitViewController alloc] init];
splitViewContr.viewControllers = [NSArray arrayWithObjects:userListNavController,userDetailsNavController, nil];
splitViewContr.tabBarItem.image=kImage;
splitViewContr.title=@"Update User";
NSMutableArray *viewControllerArray = [[NSMutableArray alloc] init];
[viewControllerArray addObject:tab1];
[viewControllerArray addObject:tab2];
[viewControllerArray addObject:tab3];
[viewControllerArray addObject:tab4];
[viewControllerArray addObject:splitViewContr];
self._tabBarController.viewControllers=viewControllerArray;
[viewControllerArray release];
[self._tabBarController dismissModalViewControllerAnimated:NO];
}
UserListViewController.m
tableViewがあります。私はただdidSelectRowAtIndexPath
方法を示しています:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger item = [indexPath row];
NSNumber *detailItem = [NSNumber numberWithInteger:item];
userDetails = [[UserDetailsViewController alloc] init];
[self.userDetails setDetailItem:detailItem];
//self.userDetails.detailItem=detailItem;
}
UserDetailsViewController.m
- (void)setDetailItem:(NSNumber *)newDetailItem
{
if (detailItem != newDetailItem) {
[detailItem release];
detailItem= [newDetailItem retain];
NSLog(@"DETAILS%@",detailItem);
[self configureView];
}
}
- (void)configureView
{
if (self.detailItem) {
[self viewDidLoad];
//incomLabel.text=[NSString stringWithFormat:@"I got Demo %d",[detailItem integerValue]];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor=[UIColor whiteColor];
self.title=@"Update User Details";
incomLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 100, 250, 20)];
incomLabel.text=[NSString stringWithFormat:@"I got Demo %d",[detailItem integerValue]];
[self.view addSubview:incomLabel];
[incomLabel release];
}
詳細クラスのラベルテキストをマスタークラスからのデータで変更する方法。ありがとう