i want to use EGOphotoviewer in my app such like that when user press button, instead of loading tableView of rootviewController, it just navigate to photos, can anyone help me ?
here i don t want tableView i just need a button for photos
The demo project is using a UITableViewController subclass called rootViewController and on the didSelect method it is just initializing the EGOPhotoViewerController and pushing it. All you need to do is instead of using a UTableViewController subclass, use a UIViewController subclass, add a button inside its view, create an action for that button, and inside the action, do the exact same thing ::
MyPhoto *photo = [[MyPhoto alloc] initWithImageURL:[NSURL URLWithString:#"http://a3.twimg.com/profile_images/66601193/cactus.jpg"] name:#" laksd;lkas;dlkaslkd ;a"];
MyPhoto *photo2 = [[MyPhoto alloc] initWithImageURL:[NSURL URLWithString:#"https://s3.amazonaws.com/twitter_production/profile_images/425948730/DF-Star-Logo.png"] name:#"lskdjf lksjdhfk jsdfh ksjdhf sjdhf ksjdhf ksdjfh ksdjh skdjfh skdfjh "];
MyPhotoSource *source = [[MyPhotoSource alloc] initWithPhotos:[NSArray arrayWithObjects:photo, photo2, photo, photo2, photo, photo2, photo, photo2, nil]];
EGOPhotoViewController *photoController = [[EGOPhotoViewController alloc] initWithPhotoSource:source];
[self.navigationController pushViewController:photoController animated:YES];
[photoController release];
[photo release];
[photo2 release];
[source release];
And you'll get what you want.
Hope this helps
Related
I've set up a void method which is called from another class if the user touches the button.
However, I got this error with "whose view is not in window hierarchy" and then I found this: whose view is not in the window hierarchy. I just want to call the method below but I got this error and it doesn't show me the navigatoncontroller. It says Warning: Attempt to present <UINavigationController: 0xae34f10> on <ViewController: 0xae1f200> whose view is not in the window hierarchy!
I don't know if this is possible to call the method from the viewDidAppear or from somewhere that it only works if the button was tapped on the other view before. If I call a NSLog in the method it shows me the NSLog in the output. Only the presenting of the navController doesn't seems to work. I would be happy if someone could help me with this.
My method:
- (void) launchGalleryView
{
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
// Set browser options.
browser.wantsFullScreenLayout = YES;
browser.displayActionButton = NO;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:browser];
NSMutableArray *photos = [[NSMutableArray alloc] init];
MWPhoto *photo;
photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:#"calculator" ofType:#"jpg"]];
photo.caption = #"The calculator is soo beauteful...";
[photos addObject:photo];
self.photos = photos;
[self presentModalViewController:navController animated:YES];
}
Just forgot to say: The MWPhotoprowser is a class which actually does't matter.
Thanks in advance.
The error message is pretty clear -- you're trying to present the controller from this class, but the class that has the button you pressed is the one whose view is in the view hierarchy. You either need to present it from the class with the button, or get back to this class however you're doing that, and then call it after viewDidAppear.
i checked your project.. wasn't able to sort out the proper issue..
but i tried a hack and it worked..
replace this line with
[self presentModalViewController:navController animated:YES];
this
[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentModalViewController:navController animated:YES];
I am using a UIButton, on clicking it I want to display the contents that are present in my NSMutableArray in UITableView with the help of UIPopOverController i.e. I want a UITableView to pop up whose cells show the contents of my NSMutableArray.
I am using the following lines of code:
UITableViewController *table= [[UITableViewController alloc]init];
table.delegate = self;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:table];
self.popoverController = popover;
popoverController.delegate = self;
NSString *hDir = [NSHomeDirectory() stringByAppendingPathComponent:#"Documents"];
NSString *hFilePath = [hisDir stringByAppendingPathComponent:#"hhhh.txt"];
NSArray *array = [NSArray arrayWithContentsOfFile:hFilePath ];
NSMutableArray *kkkk = [[NSMutableArray alloc] init];
for (NSDictionary *dict in array) {
[kkkk addObjectsFromArray:[dict allKeys]];
}
table = [[UIImageView alloc] initWithFrame:[window bounds]];
// Set up the image view and add it to the view but make it hidden
[window addSubview:table];
table.hidden = YES;
[window makeKeyAndVisible];
I am unable to get the UITableView to pop up on the press of my UIButton. Can anyone help me to sort it out?
One way to show the UITableView in the UIPopOverController is by creating a new UIViewController class. And invoking it in initWithContentViewController method of UIPopOverController.
1. Create a new UIViewController or UITableViewController class. Create an instance of it.
2. Use the instance in the initWithContentViewController method of UIPopOverController.
3. Mention from where it should "pop"
For Example in your Button action :
-(IBAction)yourButtonAction:(id)sender
{
YourNewViewController*newVC=[[YourNewViewController alloc]init];
UIPopoverController*somePopOver=[[UIPopoverController alloc]initWithContentViewController:catergoryVC]; //Tell which view controller should be shown
[somePopOver setPopoverContentSize:CGSizeMake(200, 200)]; // set content size of popover
[somePopOver presentPopoverFromRect:yourButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES]; //From where it should "pop"
}
It seems you want to present it from a UIBarButtonItem so instead of presentPopoverFromRect use presentPopoverFromBarButtonItem
[somePopOver presentPopoverFromBarButtonItem:yourBarButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
If you want to display popover on press of button click, then first add your button in viewcontroller, display that view controller as follows:
In app delegate write code:
MyViewController *viewController = [[MyViewController alloc] init];
[self.window addSubView:viewController.view];
In MyViewController add button and provide target to that button displayPopup as follows:
-(void)displayPopup:(id)sender
{
UITableViewController *tblViewPopover = [[UITableViewController alloc] init];
tblViewPopover.tableView.delegate = self;
tblViewPopover.tableView.dataSource = self;
tblViewPopover.tableView.backgroundColor = [UIColor whiteColor];
tblViewPopover.tableView.separatorStyle= UITableViewCellSeparatorStyleSingleLine;
float theWidth = 280;
tblViewPopover.contentSizeForViewInPopover = CGSizeMake(theWidth,200);
if(m_popOvrController){
[m_popOvrController dismissPopoverAnimated:NO];
[m_popOvrController release];
m_popOvrController=nil;
}
m_popOvrController = [[UIPopoverController alloc] initWithContentViewController:tblViewPopover];
[tblViewPopover release];
[m_popOvrController presentPopoverFromRect:sender.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
}
and you can use tableview delegate methods to display data in tableview.
I think, UIPopoverViewController is initialized using UIViewController and here you are using UIView(UITableView).
Can you please try using UITableViewController instead?
Also, if things does not work according to plan when you create it using the code try using an XIB explicitely.
This should help.
I have looked at several tutorials and different posts and can't seem to figure this out. I am simply trying to create a back button to take me back to a view where I was before. In the IB I create the button and link it to my backButton method. However, when I try to use it in the App I can't get it to work. Do I have to push it on the stack first? Any suggestions?
-(void)backButton:(id)sender{
[self.navigationController popViewControllerAnimated:YES];
}
Here is the code where I navigate from one view into another: Map is a view I use.
- (void) buttonClicked:(id)sender
{
UIButton *selectedButton = (UIButton *)sender;
int tempButtonTag = selectedButton.tag;
Map *map =[[Map alloc] initWithNibName:nil bundle:nil];
NSMutableString *tempID = [buttonIDArray objectAtIndex:tempButtonTag];
NSMutableString *tempType = [buttonTypeArray objectAtIndex:tempButtonTag];
[map setXmlID:tempID];
[map setXmlType:tempType];
buttonIDArray = nil;
buttonTypeArray = nil;
[buttonIDArray release];
[buttonTypeArray release];
[self presentModalViewController:map animated:YES];
}
The opposite of presentModalViewController is dismissModalViewController.
The opposite of pushViewController is popViewController.
You are mixing these up...
I am using EGOPhotoViewer to load up a bunch of images from the web. They are shown in thumbnails first, so when a user clicks on one of the thumbs, I want to show that image in the EGOPhotoViewer first. So, if I clicked the 5th image, it would load the image viewer starting at 5 of 20 or whatever.
Is there a way to do this?
ZSPhoto *photo;
for (Asset *a in items) {
photo = [[ZSPhoto alloc] initWithImageURL:[NSURL URLWithString:a.imgURL] name:a.caption];
[photos addObject:photo];
[photo release];
}
// Photosource
ZSPhotoSource *photoSource = [[ZSPhotoSource alloc] initWithPhotos:[NSArray arrayWithArray:photos]];
EGOPhotoViewController *photoController = [[EGOPhotoViewController alloc] initWithPhotoSource:photoSource];
// Set starting photo index here?
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:photoController];
navController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
navController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:navController animated:YES];
[navController release];
[photoController release];
I was running into the same problem, What I was doing was trying to moveToPhotoAtIndex: before pushing it to the navigationController. You need to do it after.
here is how i got it to work for my application...
// gets indexPath from tableView
-(void)showSelectedPhoto:(NSIndexPath *)indexPath{
// Already had photoControllerView declared in header, init with your photo source
photoControllerView = [[EGOPhotoViewController alloc] initWithPhotoSource:source];
// pushed the photoControllerView to the navigation controller
[self.navigationController pushViewController:photoController animated:YES];
// THEN you moveToPhotoAtIndex and it should work correctly!
[photoController moveToPhotoAtIndex:indexPath.row animated:NO];
}
Hope this helps clarify things!
There is a method moveToPhotoAtIndex:animated: that you should be able to use.
i am using same process to load the images in image viewer. and app is working fine for me..you can get the code from here
selected image wouldnt load in ego image viewer in ios 7
hope you will get help.
I'm stuck on something.
I'm using three20 and the TTTNavigator example. Where I can find a TabBarController that is using :
[self setTabURLs:[NSArray arrayWithObjects:#"tt://crush",
#"tt://crushes",
nil]];
to create each tab.
Ok until here all is ok, my problem is that I have all my tabs without title and image. I know how to set individual when it loads the view controller inside - (void)viewDidLoad :
self.title = #"crush";
UIImage* image = [UIImage imageNamed:self.title];
self.tabBarItem = [[[UITabBarItem alloc] initWithTitle:self.title image:image tag:0] autorelease];
but this is a problem because when you init the app all the tabs except the selected are empty.
Any suggest on how to implement that.
Ok I've resolved, I used the -init method of each view controller.. like usually... but what I need to change was :
[self setTabURLs:[NSArray arrayWithObjects:#"tt://crush/1",
#"tt://crushes/2",
nil]];
And in the map :
[map from:#"tt://crush/(init)" toViewController:[MakeCrushViewController class]];
[map from:#"tt://crushes/(init)" toViewController:[MyCrushesViewController class]];
for me right now it looks pretty weird.. but ok is working, don't ask me why you need to set 1 and 2 before the links.. if I set 1 on each it crashes...
This guy had an answer to this question in this blog post.1
Basically, within your tab view controller, just access the your view controllers
like you would without three20. In your tab view controller implimentation file
-(void)viewDidLoad{
[super viewDidLoad];
NSArray *tabs = [self viewControllers];
UIViewController *home = [tabs objectAtIndex:0];
home.tabBarItem.image = [UIImage imageNamed:#"redo.png"];
UIViewController *activities = [tabs objectAtIndex:1];
activities.tabBarItem.image = [UIImage imageNamed:#"restart.png"];
UIViewController *map = [tabs objectAtIndex:2];
map.tabBarItem.image = [UIImage imageNamed:#"lock.png"];
}