在我的应用程序中,在左侧tableview中的splitViewController中,列出了我的联系人。点击联系人后,我想将其联系人ID传递给detailViewController。并且在detailViewController的viewDidLoad方法中调用一个方法来访问webservice并提取该联系人ID的联系人详细信息并在detailViewController中显示它们。这是逻辑。但是我在单击tableView时调用detailViewController有问题。一旦我点击tableview,没有调用DetailViewController的ViewDidLoad方法(我在ViewDidLoad中没有打印的详细页面中的NSlog)
我附上了rootViewController的didSelectRowAtIndexPath方法的代码。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
if([serachBar.text isEqualToString:@""] || serachBar.text == nil)
{
NSString *ContactIdStr=[NSString stringWithFormat:@"%@",[[objectsForCharacters objectForKey:[arrayOfCharacters objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row]];
NSArray *afterSeprate = [[NSArray alloc]init];
afterSeprate = [ContactIdStr componentsSeparatedByString:@"+"];
//NSString *cellText = [afterSeprate objectAtIndex:0];
NSString *detailText = [afterSeprate objectAtIndex:1];
appdelegate.contactId=[NSString stringWithString:detailText];
}
else
{
serachBar.text = nil;
NSString *ContactIdStr=[NSString stringWithFormat:@"%@",[searchArray objectAtIndex:indexPath.row]];
NSArray *afterSeprate = [[NSArray alloc]init];
afterSeprate = [ContactIdStr componentsSeparatedByString:@"+"];
//NSString *cellText = [afterSeprate objectAtIndex:0];
NSString *detailText = [afterSeprate objectAtIndex:1];
appdelegate.contactId=[NSString stringWithString:detailText];
}
// Pass the selected object to the new view controller.
detailViewController = [[DetailView_iPad alloc] initWithNibName:@"DetailView_iPad" bundle:nil];
[detailViewController.navigationController pushViewController:detailViewController animated:YES];
//self.detailViewController.navigationController
[ContactTableview deselectRowAtIndexPath:indexPath animated:YES];
}