問題描述
我正在嘗試編寫非常簡(jiǎn)單的 iOS5 應(yīng)用程序,只搜索特定類型的數(shù)據(jù).
I'm trying to write really simple iOS5 app just searching for specific type of data.
它包含兩個(gè)屏幕,用戶將一些數(shù)據(jù)放入第一個(gè)屏幕,應(yīng)用程序檢查數(shù)據(jù),如果數(shù)據(jù)有效,應(yīng)用程序?qū)⑦M(jìn)行搜索并在新屏幕上顯示結(jié)果.
It contains two screens, the user puts some data in the first, the app checks the data and if it is valid, the app will do a search and show result on new screen.
我對(duì) iOS 和故事板完全陌生,我閱讀了很多教程,但無法弄清楚如何檢查輸入并正確切換到新屏幕.
I'm completely new to iOS and storyboards, I read quite a few tutorials, but haven't been able to figure out how to do the checking of input and switching to new screen properly.
對(duì)于 iOS5,我想我應(yīng)該使用 segue,但這都是自動(dòng)的.即使我可以在 prepareForSegue 方法中添加一些代碼,但如果檢查失敗,我找不到如何阻止 segue 發(fā)生的方法,或者我是否試圖完全錯(cuò)誤地這樣做?
With iOS5 I guess I should use segue but that's all automatic. Even though I can put some code in prepareForSegue method, I couldn't find a way how to stop the segue from happening if the check fails, or am I trying to do it completely wrong?
推薦答案
您可以通過 ctrl 從底部的 viewController 圖標(biāo)拖動(dòng)到目的地來創(chuàng)建通用"segue.此 segue 不會(huì)與任何操作相關(guān)聯(lián).然后在您的代碼中,事件正在使用您想要觸發(fā) segue 調(diào)用的條件代碼:
You can create "generic" segue by ctrl dragging from the viewController icon at the bottom to the destination. This segue won't be associated with any action. Then in your code where ever the event is using your conditional code that you want to trigger the segue call:
- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender
這篇關(guān)于做“條件轉(zhuǎn)場(chǎng)"的正確方法在 iOS5 中的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!