我有一個像userName,DOB,註冊編號:和地址,我創建了10個XIB文件 細節查看哪個是打開的當點擊MasterView表單元格,在第二個詳細信息視圖的XIB文件我有一個用戶的信息,當我選擇第二個Xib中的用戶時,如何在我的第3至第10個XIB中訪問該數據?我不知道iphone中的數據委託bcoz新的iPhone開發?詳細數據訪問與多個Xib詳細
回答
在我對你的項目的理解:
- 你開始與MasterViewController(第一控制器)
- 選擇或點擊一個行/單元格後,另一個控制器負載包含 用戶的列表? (我不太確定),其中每個用戶都有信息(包含userName,DOB等)。所以,這意味着在這個控制器中 - 您將這些信息分配給相應的用戶。 (第二個控制器)
- 然後,當您選擇一個特定的用戶時,另一個控制器將加載您要使用該控制器數據的位置 - 可能是,這是您要顯示從第二個控制器分配的信息的位置。 (第三控制器)
所以,如果我們是在同一頁上,這裏就是你要去做的事:
(比方說,你用的MainView(FirstController)和你」做在SecondViewController)
對於初學者來說已經再次,你可以做這樣的事情:
- 創建於ThirdViewController一個全局變量,將舉行由SecondViewController傳遞的信息。在這種情況下,
///////// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ///////// /////////〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜~~ThirdViewController.h〜〜〜〜〜〜〜〜 ~~~~~~~~~~~~~~~~~~~~ ///////// ///////// ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~ /////////
@interface ThirdViewController:UIViewController{
NSDictionary *dictInformation;
}
@property (nonatomic, retain) NSDictionary *dictInformation;
@end
@implementation ThirdViewController
@synthesize dictInformation;
...
// some codes here...
// you can use the information passed from the SecondViewController
...
- (void)dealloc{
[dictInformation release], dictInformation = nil;
[super dealloc];
}
@end
///////// ~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ///////// ///////// ~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ SecondViewController.h ~~~~~~~~~~~~~~~~~~~~~~//// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~ /////////
@implementation SecondViewController
// This is the assignment of data. You can put this in viewDidload
// user 1
NSMutableDictionary *aUser1 = [[NSMutableDictionary alloc] init];
[aUser1 setObject:@"josh123" forKey:@"userName"];
[aUser1 setObject:@"01-01-1987" forKey:@"dateOfBirth"];
[aUser1 setObject:@"12345678" forKey:@"regNumber"];
[aUser1 setObject:@"24-H 1st St. New York" forKey:@"address"];
// user 2
NSMutableDictionary *aUser2 = [[NSMutableDictionary alloc] init];
[aUser2 setObject:@"josh321" forKey:@"userName"];
[aUser2 setObject:@"01-02-1988" forKey:@"dateOfBirth"];
[aUser2 setObject:@"87654321" forKey:@"regNumber"];
[aUser2 setObject:@"42-H 1st St. New York" forKey:@"address"];
// I assigned all users to an array
NSArray *arrayOfUsers = [[NSArray alloc] initWithObjects:aUser1, aUser2, nil];
[aUser1 release];
[aUser2 release];
// Pass the value of arrayOfUsers somewhere to that it can be accessed
// or it can be a
/* At this point, the following has values:
arrayOfUsers[0] = aUser1 -> {'josh123', '01-01-1987', '12345678', '24-H 1st St. New York'}
arrayOfUsers[1] = aUser2 -> {'josh321', '01-02-1988', '87654321', '42-H 1st St. New York'}
*/
// You can actually add the following codes anywhere, depending on your implementation. It can be when you clicked a cell or a button, etc.
ThirdViewController *thirdViewController = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
// assign a dictionary value to dictInformation which is found in ThirdViewController
// If you are using UITableView, then, this should be done when you are selecting a cell in the tableView and the value of the index should be indexPath.row
[thirdViewController setDictInformation:[arrayOfUsers objectAtIndex:0]];
// This pushes to the ThirdViewController
[self.navigationController pushViewController:thirdViewController animated:YES];
[thirdViewController release];
...
@end
注意:這僅僅是一個代碼片段......我只想給你一個關於如何去做的想法。但希望這有助於。祝你好運! :)
- 1. 1wire問題詳細
- 2. Android主詳細信息詳細信息
- 3. Crystal Reports詳細信息詳細信息
- 4. 主詳細界面中詳細信息的多重視圖
- 5. 網站訪問者的詳細信息
- 6. 訪問SIM卡的詳細信息
- 7. 訪問JSON對象的詳細信息
- 8. Cmdlet詳細流
- 9. 異常詳細
- 10. 詳細講解
- 11. 獲取詳細
- 12. JAXB unmarshalling詳細
- 13. 擦除詳細?
- 14. 更多詳細資料(ARC)
- 15. ActiveReports多列詳細信息
- 16. Diskpart詳細磁盤與PowerShell
- 17. 以數據庫爲源的詳細信息獲取詳細元素的數量
- 18. 通過程序訪問詳細的歷史財務數據
- 19. asp.net詳細信息視圖編程數據訪問
- 20. 創建一個'詳細'頁
- 21. 詳細視圖按鈕打開另一個詳細視圖根據sqlite db
- 22. Django詳細查詢
- 23. 詳細使用Rocket.Chat.Cordova
- 24. 休眠:GenericGenerator詳細
- 25. FUSE - 詳細文檔
- 26. HKWorkoutActivityType詳細文檔?
- 27. Master - 詳細示例
- 28. Checkstyle詳細解答?
- 29. bad_alloc詳細介紹?
- 30. RadGrid主/詳細Telerik