Plist按钮中的下一项 [英] Next Item in Plist Button

查看:132
本文介绍了Plist按钮中的下一项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,我有一个简单的应用程序,只是在一个图像视图中的大量图像。每个都只包含在plist文件中,并在弹出窗口中选择单元格时调用。我想要的只是一个按钮,其中包含一个动作以获取plist中的下一个项目并在图像窗口中显示。这听起来很容易,但我无法弄清楚在plist中抓住下一个项目的代码?任何人都可以帮助欢呼

Hey guys, i have a simple app just a load of images in one image view. Each is just included in a plist file and called when a cell is selected in popover window. All i want is a button with an action to get next item in plist and display in the image window. this sounds easy but i cant figure out the code to grab next item in plist? can anyone help cheers

推荐答案

我不确定你的财产清单的结构是什么,但我只是要去猜测它只是一个属性列表,其中一个字符串包含每行的图像名称。管理这个的最简单方法是将plist文件转储到这样的数组中:

I'm not sure what the structure of your property list is, but I'm just going to guess that it's just a property list with one string containing the image name per row. The easiest way to manage this is to just dump the plist file into an array like this:

// Load the data 
NSString *pathToFile = [[NSBundle mainBundle] pathForResource:someArrayNameString ofType:@"plist"];
self.someArrayYouCreated = [NSArray arrayWithContentsOfFile:pathToFile];

然后你可以像这样访问数组中的数据:

then you can access the data in the array like this:

// load it into some string you created
nextImageNameString = [someArrayYouCreated objectAtIndex:nextImageNumberHere];

然后您可以使用该字符串名称作为下一个要加载的图像。所以基本上,

and then you can just use that string name as the next image to load. So basically,


  1. 将plist转储到数组中

  2. 使用 objectAtIndex 访问图像(记住,数组从索引0开始)

  1. Dump plist into an array
  2. Use objectAtIndex to access the images (remember, arrays start at index 0)

这篇关于Plist按钮中的下一项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆