久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

將數據傳回前一個控制器

Pass data back to the previous controller(將數據傳回前一個控制器)
本文介紹了將數據傳回前一個控制器的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我在故事板中有兩個控制器,嵌入在 NavigationController 中,并且有一個 segue 可以在它們之間切換.

I have two controllers in the storyboard, embedded in a NavigationController, and there is a segue to switch between these.

通過實現 prepareForSegue 將數據從第一個控制器傳遞到第二個控制器非常簡單,并使用 segue.destinationViewController 設置第二個控制器的屬性.

Passing data from the first controller to the second one is pretty straightforward by implementing prepareForSegue, and set the properties of the second controller using segue.destinationViewController.

我也應該將數據從第二個控制器傳回到前一個控制器.我用谷歌搜索,但我沒有找到任何簡單但有效的代碼來演示它.

I should pass back data to the from the second controller to the previous one also. I googled, but I have not found any simple, but working code to demonstrate it.

您能不能給我一個簡單的示例,說明最好的方法?

Would you be so kind give me a simple sample about the best way to do it?

提前致謝!

推薦答案

在您的第二個視圖控制器類中,您創建一個協議和委托.第一個視圖控制器將自己設置為 prepareForSegue 中的委托并實現協議方法.然后,第二個視圖控制器將調用方法將數據傳回第一個視圖控制器.以下是我的一個項目中的一些代碼作為示例.

In your second view controller class you create a protocol and delegate. The first view controller will set it self as the delegate in prepareForSegue and implement the protocol methods. The second view controller will then call the methods to pass data back to the first view controller. Here is some code from one of my projects as an example.

@protocol TableSelectorDelegate <NSObject>

@optional
- (void)didMakeSelection:(id)selectionString forType:(NSString *)dataTitle;
- (void)didAddNewValue:(NSString *)newValue forType:(NSString *)dataTitle;

@end

@interface TableSelectorViewController : UITableViewController  

@property (nonatomic, weak) id<TableSelectorDelegate> delegate;

@end

這篇關于將數據傳回前一個控制器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動運行/壓力測試 iOS 應用程序以找出罕見 UI 錯誤的原因?)
Can#39;t change target membership visibility in Xcode 4.5(無法更改 Xcode 4.5 中的目標成員身份可見性)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態和動態單元格中處理單元格選擇)
How to remove Address Bar in Safari in iOS?(如何在 iOS 中刪除 Safari 中的地址欄?)
iOS 5 SDK is gone after upgrade to Xcode 4.5(升級到 Xcode 4.5 后,iOS 5 SDK 消失了)
Having trouble creating UIImage from CIImage in iOS5(在 iOS5 中從 CIImage 創建 UIImage 時遇到問題)
主站蜘蛛池模板: 91亚洲精品在线 | 一区二区在线免费观看 | 一级片在线观看视频 | 天天操网站 | 欧美精品一区二区在线观看 | 日韩精品视频在线 | 成人在线精品 | 亚洲狠狠干 | av网站在线免费观看 | 欧美在线不卡 | 蜜臀久久99精品久久久久宅男 | www.久久久久 | 亚洲免费视频网站 | 日韩黄色片 | 久久高清免费视频 | 国产黄色精品视频 | 青青草视频免费在线观看 | 亚洲精品字幕在线观看 | 亚洲黄色片 | 中文字幕二区 | 亚洲免费观看视频 | 欧美一级精品 | 中文字幕丰满人伦在线 | 日韩欧美在线播放 | 欧美福利一区 | 中文字幕在线播放视频 | 亚洲欧美日韩国产精品 | 性生活视频网站 | 色香蕉网 | 99久久久国产精品 | av大片在线观看 | 一级黄色片免费观看 | 日批视频免费在线观看 | 青青艹在线视频 | 亚洲免费视频观看 | 日韩免费一区二区 | 神马久久久久久 | 国产福利视频在线 | 久久精品在线视频 | 三级黄色片 | 日韩视频二区 |