Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-14-2012, 10:52 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 8
chris Good is on a distinguished road
Default loop Nsmutable arrray of uiimages from end to beginning

I have an NSMUtable array of images where a different image is displayed with a previous and a next button, but when I get to the end of the array the simulator crashes. I want to loop the end of the array to the beginning so that when I get to the end of the array of images when I hit the next button again it loops back to the first image, also when Im at the first image if I hit the previous button it loops to the last image with no crashes
chris Good is offline   Reply With Quote
Old 01-14-2012, 10:59 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 196
phillipie99 is on a distinguished road
Default

On the actions for the button presses, before you change the image check the index of the image you are about to set. If it is smaller than 0, set it to the highest index in the array (array.count), and if it is larger than highest index in the array (array.count) set the index to 0.

here is some psudo code
Code:
-(IBAction)NextImage
{
if (index > array.count)
index = 0;

...change image here
}

-(IBAction)LastImage
{
if (index < 0)
index = array.count;

...change image here
}
__________________
My new app Catch The Coconut.
Website: PhilBystricanApps.com
phillipie99 is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, nsmutable array, uiimages, xcode

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 390
10 members and 380 guests
7twenty7, Atatator, glenn_sayers, guusleijsten, iphonedevshani, QuantumDoja, sacha1996, Sami Gh, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:42 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0