- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
RightViewController *rightViewController = [[RightViewController alloc] initWithNibName:@"RightViewController"bundle:nil];
//[self.navigationController pushViewController:rightViewController animated:YES];
if(indexPath.row == 0)
{
UILabel *infoLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, 450, 150)];
infoLabel.text = @"Customer:Barrick \r\n Mine:gold \r\n Location:USA";
[rightViewController.view addSubview:infoLabel];
UITableView *mapTable = [[UITableView alloc]initWithFrame:CGRectMake(165, 5, 450,150)style:UITableViewStyleGrouped];
[rightViewController.view addSubview:mapTable];
}
if(indexPath.row == 1)
{
UILabel *infoLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, 450, 150)];
infoLabel.text = @"Eqipement";
[rightViewController.view addSubview:infoLabel];
}
if(indexPath.row == 2)
{
image view..
}
[rightViewController release];
}
答案 0 :(得分:1)
不要尝试从其他控制器渲染视图。单击该行时,将行的索引值传递给rightView控制器。然后根据rightView控制器中的行值渲染视图。
答案 1 :(得分:1)
您必须将值传递给右视图控制器,您还必须为右视图控制器设置委托。
在左视图控制器中定义右视图控制器,如:
RightViewController *detail;
/// in implementation of left view contrloller
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSUInteger item = [indexPath row] +1;
NSNumber *detailItem = [NSNumber numberWithInteger:item];
self.detailCar.detailItem = detailItem;
}
在rightViewController.h文件中定义:
@property (retain, nonatomic) NSNumber *detailItem;
在RightViewController的实现文件中:
- (void)setDetailItem:(NSNumber *)newDetailItem {
NSLog(@"ConfigTItem");
if (_detailItem != newDetailItem) {
[_detailItem release];
_detailItem = [newDetailItem retain];
[self configureView];
}
else {
[self configureView];
}
}
- (void)configureView {
if (self.detailItem) {
[self viewDidLoad]; //
//set your method's and variable whatever you want to do in your view did load or directly here
}
}