[英]How to navigate back to the previous view
當用戶單擊TableViewController
的一行時。 我要選擇該視圖的內容,並且用戶應導航回到上一個屏幕。
我怎樣才能做到這一點。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// How to navigate back to the previous view ?
}
請注意,這是一個基於Navigation Controller
的應用程序。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:`(NSIndexPath *)indexPath {`
[self.navigationController popToRootViewControllerAnimated:YES];
}
[self.navigationController popToViewController:[YOUR ViewContoller]]動畫:是];
這是返回特定視圖控制器的最佳方法。 如果您有多個視圖控制器,則應進行循環並捕獲您的視圖控制器,並將其附加到[您的Viewcontroller]位置。
嘗試這個 :
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.