0
我正在學習tabbar內的splitViewController。我有5個選項卡,其中第五個是splitViewController。我能夠展示它。我的MasterView確實將數據發送到DetailsView。但是的DetailView標籤不顯示它使用splitViewControllers發送的數據更改uilabel文本
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;
[email protected]"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];
[email protected]"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];
}
如何從大師班傳來的數據更改詳細類標籤文本。謝謝