Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 28, 2009, 02:18 PM   #1
iLoveDeveloping
macrumors regular
 
Join Date: Sep 2009
Swiping Photo Views

Hey,

Just wondered if anyone had the code to do swiping on views, i have a new App that has photos in it and i want the user to be able to just swipe there finger along the screen and go to the next photo. How is this done?
__________________
iPhone 3G S⃣
iLoveDeveloping is offline   0 Reply With Quote
Old Oct 28, 2009, 02:21 PM   #2
iLoveDeveloping
Thread Starter
macrumors regular
 
Join Date: Sep 2009
Oh, and i have a picture on each Xib, forgot to mention that..
__________________
iPhone 3G S⃣
iLoveDeveloping is offline   0 Reply With Quote
Old Oct 28, 2009, 02:42 PM   #3
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
A simple way to do this is add the images as subviews of a scroll-view and then enable paging.
__________________
dejo is offline   0 Reply With Quote
Old Oct 28, 2009, 02:58 PM   #4
iLoveDeveloping
Thread Starter
macrumors regular
 
Join Date: Sep 2009
Quote:
Originally Posted by dejo View Post
A simple way to do this is add the images as subviews of a scroll-view and then enable paging.
OH ok, that sounds better, would only need one view then, can you tell me how to do this? or show me where i can find out?
__________________
iPhone 3G S⃣
iLoveDeveloping is offline   0 Reply With Quote
Old Oct 28, 2009, 03:14 PM   #5
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Using NSXMLParser to Pull UIImages From the Web

This covers other topics, like XML parsing, that you may want to ignore but should get you headed in the right direction. If not, Google around. There's more out there.
__________________
dejo is offline   0 Reply With Quote
Old Oct 28, 2009, 05:03 PM   #6
iLoveDeveloping
Thread Starter
macrumors regular
 
Join Date: Sep 2009
Ok i got something going here, i have the scroll view all set up and it works, but i have two more questions now, its not behaving like i want it to. I want to create something like the default 'Photos' on every iPhone, i want to go through each photo and have it stop at each one.

Here is the code im using:

.h:

Code:
#import "MainView.h"

@implementation MainView
- (IBAction)gotoscrollview {
	myscrollview.contentSize = CGSizeMake(2000, 480);
	[self addSubview:myscrollview];
    
}
@end
.m:
Code:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface MainView : UIView {
    IBOutlet UIView *myextraview;
    IBOutlet UIScrollView *myscrollview;
}
- (IBAction)gotoscrollview;
@end
And two, this might seem silly, but say i want to put in 10 photos, and i have one UIScrollingView to have all those photos in, how do i fit them all in in interface builder, a mac screen can not fit in 10 photos wide, how do i fit them all in one big line?
__________________
iPhone 3G S⃣
iLoveDeveloping is offline   0 Reply With Quote
Old Oct 28, 2009, 05:15 PM   #7
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by iLoveDeveloping View Post
...its not behaving like i want it to
What's it doing instead?

Quote:
Originally Posted by iLoveDeveloping View Post
And two, this might seem silly, but say i want to put in 10 photos, and i have one UIScrollingView to have all those photos in, how do i fit them all in in interface builder, a mac screen can not fit in 10 photos wide, how do i fit them all in one big line?
You probably want to find another way other than Interface Builder to add your images then.
__________________
dejo is offline   0 Reply With Quote
Old Oct 28, 2009, 05:26 PM   #8
iLoveDeveloping
Thread Starter
macrumors regular
 
Join Date: Sep 2009
its just sliding along without stopping, like it just slides according to how hard a flick my finger and stops when it slows down, not stopping at the next image like i want it to, like the default 'Photos' App on all iPhones.

How do other people do that? i mean even in Photos App from Apple, how do they do that? they don't put your pictures into interface builder, is there a way just to link them all into the view?
__________________
iPhone 3G S⃣
iLoveDeveloping is offline   0 Reply With Quote
Old Oct 28, 2009, 05:33 PM   #9
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by iLoveDeveloping View Post
its just sliding along without stopping, like it just slides according to how hard a flick my finger and stops when it slows down, not stopping at the next image like i want it to, like the default 'Photos' App on all iPhones.
I guess you missed the part where I said you'll want to enable paging.

Quote:
Originally Posted by iLoveDeveloping View Post
How do other people do that? i mean even in Photos App from Apple, how do they do that? they don't put your pictures into interface builder, is there a way just to link them all into the view?
They do it programatically. You already know about addSubview: so you already know of the kernel of one technique. Plus, I believe there are libraries out there that will give you the functionality you desire without having to do all the heavy-lifting yourself.
__________________
dejo is offline   0 Reply With Quote
Old Oct 28, 2009, 06:09 PM   #10
iLoveDeveloping
Thread Starter
macrumors regular
 
Join Date: Sep 2009
Quote:
Originally Posted by dejo View Post
I guess you missed the part where I said you'll want to enable paging.
How would one enable paging? There is no tick box for that in IB and i don't know any code to do that?
__________________
iPhone 3G S⃣
iLoveDeveloping is offline   0 Reply With Quote
Old Oct 28, 2009, 06:19 PM   #11
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by iLoveDeveloping View Post
There is no tick box for that in IB...
Well, that's not quite true, is it?
Attached Images
 
__________________
dejo is offline   0 Reply With Quote
Old Oct 28, 2009, 06:25 PM   #12
iLoveDeveloping
Thread Starter
macrumors regular
 
Join Date: Sep 2009
Ooooops!

Sorry, did not see that! Didn't get much sleep last night, (9 hours doing an app )

Thanks,

I will see how that works out...
__________________
iPhone 3G S⃣
iLoveDeveloping is offline   0 Reply With Quote
Old Oct 28, 2009, 06:32 PM   #13
iLoveDeveloping
Thread Starter
macrumors regular
 
Join Date: Sep 2009
Does it auto detect the photos 'pages'? To know which the next one is?

Cos it seems to be doing the same.. Well, a little bit more jumpy, its jumping to the next image like i wanted but then keeps on going all the way to the next one at the end Until i stop it with my finger. (I'm only working with 3 images to start.)



EDIT:
I no i am asking a lot but this is the final thing for my App and it is driving me crazy! I just want to get it working...
__________________
iPhone 3G S⃣
iLoveDeveloping is offline   0 Reply With Quote
Old Oct 28, 2009, 06:44 PM   #14
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
As long as the scrolling stops and you don't have two pages semi-displayed in the same view then, yes, it is working as expected.
__________________
dejo is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Firefox swiping between tabs surfologist87 OS X 0 Feb 8, 2014 10:57 PM
iPad: Image swiping with ios7 Sjh42 iOS 7 3 Sep 28, 2013 09:03 AM
Swiping Between Spaces TDCorinthian OS X 10.8 Mountain Lion 0 Oct 28, 2012 01:18 AM
Swiping between tabs with your finger??? Billymcintyre iPhone 6 Oct 17, 2012 06:17 PM
Swiping between Reminders lists Hephaestus iOS 6 1 Sep 19, 2012 07:00 PM

Forum Jump

All times are GMT -5. The time now is 04:54 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC