1.代码控制storyboard中的Segue跳转
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"pushDetailView"])
{
// 点击cell就会转向详细页面.
NSArray *sourceArray;
NSIndexPath *indexPath = [self.searchDisplayController.searchResultsTableView
indexPathForCell:(UITableViewCell *)sender];
if (indexPath != nil){
sourceArray = self.searchResults;
}
else{
indexPath = [self.tableView indexPathForCell:(UITableViewCell *)sender];
sourceArray = self.records;
}
// 得到详细视图控制器
TZRecordDetailViewController *destinationController = segue.destinationViewController;
TZRecord *record = sourceArray[indexPath.row];
destinationController.title = record.name;
destinationController.record = record;
// 设置信息,并传数据过去
}
}
2.从storyboard中得到一个ViewController方法
/* -----------------从storyboard中得到视图控制器,并且初始化数据,设置信息-------------- */
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
//得到名为aaa的VC实例 也就是说在storyboard中设置的VC其实是你已链接类的一个实例
TZFriendsViewController *friendsViewController = [storyboard instantiateViewControllerWithIdentifier:@"TZFriendsViewController"];
friendsViewController.records = recordArray;
// 定义recordArray数组赋值给friendsViewController
friendsViewController.title = @"好友";
friendsViewController.tabBarItem.image = [UIImage imageNamed:@"friends"];
// 设置标题及图片
3.navigationcontroller 弹出视图方法
[self.navigationController popViewControllerAnimated:YES];
// 弹出当前视图控制器,显示前一视图
[self.navigationController popToViewController:viewController animated:YES];
// 弹出到指定视图控制器
[self.navigationController popToRootViewControllerAnimated:YES];
// 弹出到根视图控制器
setNavigationBarHidden:BOOL animated:BOOL;
// 设置导航控制器状态