我有一個名爲「MainStoryboard_iPhone.storyboard」的故事板,它有2個視圖。第一個視圖有一個帶有公開按鈕的表格單元格。我可以將表格單元格拖放到其他視圖並顯示視圖,但是隻有當用戶在不使用segue的情況下單擊附件按鈕時,才需要以編程方式進行。 2個視圖的名稱是RootViewController和ProviderLookupViewController。目前我已經試過這段代碼,但不起作用,當我點擊單元上的附件按鈕時,它會報錯。註釋行是其他的東西,我想在附件按鈕中按動視圖板
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
bundle:nil];
// ProviderLookupViewController* vc = [sb instantiateViewControllerWithIdentifier:@"ProviderLookupViewController"];
UIViewController* vc = [sb instantiateViewControllerWithIdentifier:@"ProviderLookupViewController"];
[self presentModalViewController:vc animated:YES];
//[self.navigationController pushViewController:vc animated:YES];
}
你能添加錯誤信息嗎? – zbMax
你說'2個視圖的名稱...'你的意思是UIViewController?順便說一下,使用'instantiateViewControllerWithIdentifier:'需要爲您的視圖控制器(實用程序/身份檢查器)設置標識符 – zbMax
是的,第一個是RootViewController,標識符已設置。並得到錯誤,程序收到的信號:SIGABRT – Gamerlegend