创建了一个tabbarcontroller
作为 splitview 控制器的详细视图。我可以通过单击模拟器上item1
的item2
图标来更改视图,但不能以编程方式更改视图。
我null
在尝试打印viewcontrollers
时得到nslog
。在 MasterView 中:
@property (strong, nonatomic) TabBarRootViewController *detailViewController;
- (void)viewDidLoad
{
[super viewDidLoad];
self.detailViewController=[[TabBarRootViewController alloc] init];
//tried also
self.detailViewController = (TabBarRootViewController *)[self.splitViewController.viewControllers objectAtIndex:1];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//this sends object info to detail
if (indexPath.section==0) {
//send row number
NSNumber *i = [NSNumber numberWithInteger:indexPath.row];
NSLog(@"Selected index %@",i);
self.detailViewController.detailItem = i;
}
}
详细(标签栏):
@property (strong, nonatomic) id detailItem;
if (self.detailItem) {
NSInteger i=[self.detailItem integerValue];
NSLog(@"recieved integer is %i",i);
//tried this
self.tabBarController.selectedIndex=i;
self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:i];
//list of viewcontrollers
NSArray *array;
array = [[self tabBarController] viewControllers];
NSLog(@"array %@",array);
}
NSLOG:
recieved integer is 1
array (null)
如何以编程方式更改视图?
谢谢,
小号