0

我正在标签栏中学习 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];
}

用户列表视图控制器.m

我有一个表视图。我只是展示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];

}

如何使用来自 Master 类的数据更改 Details 类中的标签文本。谢谢

4

1 回答 1

0

好的,我找到了答案。我在 AppDelegate.m 中丢失了这个东西,userlist.userDetails=userDetails;其中userDetailsUserListViewController 中的 UserDetailsViewController 对象。

于 2012-09-12T10:05:43.083 回答