开发者

cant able to exchanges elements in array

hi i am new to iPhone.what i did is creating an array with images as shown below

images = [NSMutableArray alloc] initWithObjets:@"image1.jpg",@"image2.jpg",@"image3.jpg",@"image4.jpg",@"开发者_如何学Pythonimage5.jpg",@"image6.jpg",nil]

and i create a button when ever button click images are exchanged for that i am writing code as fallows in button clicked event.

[_images exchangeObjectAtIndex:2 withObjectAtIndex:4];

but images are not exchanged and i did n't get any warnings and images.i am writing array in viewDidLoad.what is the wrong.how can i exchange elements in the array. thank u in advance.


Are you getting an array of images to then put into a UIImage so it goes through all the images one by one?

If so then when you change this array it will not change the order of the UIImages. You will need to change the array as you currently are then assign the array to the UIImage again like you would have done before. This would then show you the new and hopefully correct sequence of images.

I may be a bit wrong and you are using each location in the array to create a UIImage then put all those UIImages into a UIImageView. But what i am saying still applies, you would have to assign the new array to the UIImageView.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜