0

I want to make an wallpaper iphone app. Now if i have for example 100 wallpapers , do I have to create 100 nib files and 100 .m and .h files and 100 UIButtons for to save the wallpaper and 100 UIButton for to go to the previous or next wallpaper ? Is there any other way to do this ? Thanks !

Sacha
  • 127
  • 3
  • 11

3 Answers3

0

Of course not. I would use a UITableView for that. Or even better a custom view that looks similar to the Photos app on the iphone.

You don't want to use a UIButton to go to the previous or next photo. You want to use a UIScrollView in paging mode.
But you don't want the user to browse through your images in that way in the first place.

Create a index screen that has a UIScrollView (non-paging this time) with thumbnails of all your images. And when one is tapped it zooms in with a nice animation and you can flick to the next or previous image with the paging UIScrollView I mentioned earlier.

You know, like the Photos app.

Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
0

yes sure. save your hundred wallpapers in the resources folder. The are named like this "wp_1.png", "wp_2.png" etc. Then you create a nib with the buttons (previous, next and save) In the uiviewcontroller you'll have an int property. For instance you call it n or something like that. I would suggest adding another property for your wallpaper (UIImageView) Then you implement the methods in the view controller.

-(void)awakeFromNib {
self.n = 1;
UIImage* wallpaper = [UIImage imageNamed:@"wp_1.png"];
UIImageView* view = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)];
self.wallpaper = view;
view.image=wallpaper;
[self.view addSubview:view];
}

-(IBAction)next:(id)sender {
self.n++; // increases n by 1;
[self.wallpaper removeFromSuperview];
NSString* name = [NSString stringWithFormat:@"wp_%i.png", self.n];
UIImage* wallpaper = [UIImage imageNamed:name];
UIImageView* view = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)];
self.wallpaper = view;
view.image=wallpaper;
[self.view addSubview:view];
}

something like that. hope that helps

lbrndnr
  • 3,361
  • 2
  • 24
  • 34
0

in the header (.h file) add something like that:

int n; UIImageView* wallpaper; }

@property (readwrite) int n; @property (readwrite, retain) UIImageView* wallpaper;

in the implemention fil (.m file) :

@synthesize n, wallpaper;

lbrndnr
  • 3,361
  • 2
  • 24
  • 34
  • Thanks, that worked. But when I debug it show the wallpapers on the whole screen wich hides the next button. Is there any way to make the hide button on the wallpaper ? – Sacha Mar 13 '11 at 19:23
  • Sure. The easiest way to that is to add a new IBOutlet property for your next button like that: IBOutlet UIButton* nextButton; Then you can call from the uiviewcontroller: [self.view bringSubviewToFront:nextButton]; – lbrndnr Mar 13 '11 at 20:02