Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

estupefactika

macrumors member
Original poster
Feb 16, 2009
47
0
Alcobendas (Madrid)
Hi, what is the best way to make a image gallery? I would like to display my little images and when I click in one of them to open a detail.

a ViewController with UiScrollView?

Any suggestion? Thanks
 

estupefactika

macrumors member
Original poster
Feb 16, 2009
47
0
Alcobendas (Madrid)
Ok dejo, I'll look this methods, thanks.

I have a doubt, Ive created several UIImageViews with their tag, if they have image I set it, easy, if it not I'll set later, my question, how can I set the image to my corresponding UIImageView through their tag?
 

estupefactika

macrumors member
Original poster
Feb 16, 2009
47
0
Alcobendas (Madrid)
Hi again, Ive created a UIImageView to handle touches there.

When I click an image, in the touchesBegan method, I would like to open a ViewController with their details.

MyClass *viewController= [[MyClass alloc] initWithLink:storyLink];
[[self navigationController] pushViewController:viewController animated:YES];

but my UIImageView not respond to '-navigationController'

What way do I have to use pushViewController correctly?
 

estupefactika

macrumors member
Original poster
Feb 16, 2009
47
0
Alcobendas (Madrid)
Yes, in my AppDelegate I have a TabBarController of UINavigationControllers. When I click in the corresponding tabBarItem, I open my image gallery viewController.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Yes, in my AppDelegate I have a TabBarController of UINavigationControllers. When I click in the corresponding tabBarItem, I open my image gallery viewController.
What is "self" in this line:
Code:
[[self navigationController] pushViewController:viewController animated:YES];

and how is it defined? I.E. What does its .h look like?
P.S. Put the .h within [ CODE ] [ /CODE ] tags to make it easier to read here.
 

estupefactika

macrumors member
Original poster
Feb 16, 2009
47
0
Alcobendas (Madrid)
A summary:

My AppDelegate has a UITabBarController of UINavigationControllers. When I click in corresponding tabBarItem display my imageGalleryViewController :

imageGalleryViewController:

Code:
-(void)loadView {
//Display my image gallery in a ScrollView
//Each image belongs to a press release
for (int i=0;i<[images count];i++) {
...
MyImageViewClass *img=[[MyImageViewClass alloc] initwithFrame:CGRect(...) ];
UIImage *image=[UIImage imageNamed:@"gray.png"];
[img setImage:image];
[scrollView addSubview:img];
....
}

}

My gallery has been displayed.

My UIImageViewClass:
-Each image belongs to a press release, so I would like to open a ViewController with their press release detail.
-I have to get the press release detail in an array. All images is ordered, Example, if I click in the first image, I searh the first index of the array and I get the press release detail.
-Now, I should open my detailViewController to display the press release detail.
Code:
-(id) initWithFrame: (CGRect) aFrame {
self=[super initWithFrame:aFrame];
if (!self) return NULL;
return self;
}

-(void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {

UITouch *touch=[[event allTouches] anyObject];
int storyIndex=[touch view].tag;

NSString *storyLink=[[appDelegate.feedArray objectAtIndex:storyIndex] objectForKey:@"url"];

detailViewController *d=[[detailViewController alloc] initWithLink:storyLink];
[[self navigationController] pushViewController:d animated:YES];
}

My detailViewController:
Code:
-(id) initWithLink:link {
webView=[[UIWebView alloc] init];
NSString *urlAddress=link;
NSURL *url=[NSURL URLWithString:urlAddress];
NSURLRequest *requestObj=[NSURLRequest requestWithUrl:url];
[self.webView loadRequest:requestObj];
return self;
}

This is what I would like to do, but Ive read that ImageView has not NavigationController, by that dont works. I dont know if Ive explained good, so I dont know how i can to use the pushViewController
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
My AppDelegate has a UITabBarController of UINavigationControllers.
Are you sure about this? Because I really doubt that your UITabBarController has a set of UINavigationControllers, from the sound of things. Can you show us the code or Interface Builder inspector where you have set up the View Controllers for each of your tabs?
 

estupefactika

macrumors member
Original poster
Feb 16, 2009
47
0
Alcobendas (Madrid)
Here is in my applicationDidFinishLaunching of AppDelegate:
Code:
for (int i = 0; i < [buttonNames count]; i++) {
		switch (i) {
                    case 3:
                        viewController = [[imageGalleryViewController alloc] init];
                        break;
                    default:
			viewController = [[otherViewController alloc] initWithCategory:i ];
                    break;
                }
			UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];
			UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTitle:[buttonNames objectAtIndex:i] image:[UIImage imageNamed:[imgNames objectAtIndex:i]] tag:i];
			nav.tabBarItem = tabBarItem;
			
			[controllers addObject:nav];
			[viewController release];
			[nav release];
			[tabBarItem release];
}

// Create the toolbar and add the view controllers
	tabBarController = [[UITabBarController alloc] init];	
	[tabBarController setViewControllers:controllers animated:YES];
	tabBarController.customizableViewControllers = controllers;
	tabBarController.delegate = self;	 

	// Set up the window
	[window addSubview:tabBarController.view];

It works every tabBarItem, but I dont know how I can to open the press release detail in other view when I click in an image.

The functionality I want is like in photos app, instead of to open a image I open a viewController with a UIView with the press release detail and a 'Back button'

But I unknown what method to use to do the transition to the next view
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.