我有一個表設置,從一個plist文件接收數據,一旦你點擊一個tableview單元格,它會帶你到一個視圖控制器,顯示內容。我想在該視圖控制器的頂部有一個UIImageView,它從plist中加載。
我會如何去做呢?UIImageView從Plist
-1
A
回答
0
你可以像這樣找回plist。
NSString *path = [[NSBundle mainBundle] pathForResource:@"Name" ofType:@"plist"];
NSMutableDictionary *myDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
NSArray* allmyKeys = [myDictionary allValues];
0
實現你正在尋找什麼的正確方法取決於你plist包含的信息。 假設您的plist是一個簡單的路徑,圖像資產列表,你可以添加以下有問題的視圖控制器的viewDidLoad
功能:
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"nameOfPList" ofType:@"plist"];
NSArray *contentArray = [NSArray arrayWithContentsOfFile:plistPath];
NSString *pathToFile = [contentArray objectAtIndex:0]; // Assumes plist contains paths to images
UIImage *image = [[UIImage alloc] initWithContentsOfFile:pathToFile];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.view addSubview:imageView]; // Add the newly instantiated UIImageView to the controller's view
}
相關問題
- 1. 從.plist填充UIImageView
- 2. 從PLIST
- 3. Objc:從plist中
- 4. 從plist中
- 5. 整數從.plist
- 6. 從plist中
- 7. 從plist到UIPickerView
- 8. 從plist中
- 9. Loadin網址的plist從plist中
- 10. iOS - PLIST - 從plist中訪問其他plist值
- 11. 閱讀從uiimageView
- 12. 從UIImageView的
- 13. 從一個UIImageView
- 14. UIImageView從NSMutableArray
- 15. 從UIImageView的
- 16. 如何使用plist NSString項目作爲UIImageView對象名稱
- 17. 從plist讀到NSArray
- 18. 嵌套從plist NSDictionary
- 19. 如何從plist中
- 20. 陣列從plist中
- 21. 從kext讀取plist
- 22. 的iOS:從plist中
- 23. 從文件的.plist
- 24. 從plist加載NSMutableDictionary
- 25. 從信息的plist
- 26. 從plist中讀取
- 27. 從plist中讀取
- 28. 從字典的plist
- 29. 從Plist中搜索
- 30. 從plist創建NSArray
什麼數據從你的plist中來嗎?圖像文件的名稱/位置? – zeantsoi
你到目前爲止嘗試過什麼? – Tirth
http://stackoverflow.com/questions/10846620/ios-load-image-from-plist-file可以在這裏檢查 – 012346