In the iPod application in my iphone, i see a more button in the tabbar controller. When i click it i see the other tabs that are not shown in the tababrcontroller.
I need to know how to add an image in front of the name in the tableview that appears as a result of clicking the More button.
Here's an image that will show you what exactly i want to achieve
2.) How to add an image to a button, finally it should appear in the format [image][text]
Do it like this for each View Controller that you'll be adding to your Tab Bar:
viewTab1controller = [[ViewTab1Controller alloc] initWithNibName:#"ViewTab1" bundle:nil];
viewTab1controller.title = #"Title";
navigationTab1Controller = [[[UINavigationController alloc] initWithRootViewController:viewTab1controller] autorelease];
navigationTab1Controller.tabBarItem.image = [[UIImage imageNamed:#"icon.png"] autorelease];
[viewTab1controller release];
If you do it for each "tab" it should work for the other icons.
you can use the following
cell.imageView.image = [[UIImage alloc] initWithData: data];
Where cell is the UITableViewCell
Related
I have UITabBarController and push on two views. I want the first view to be the default and the button to be in the "selected" state when it loads.
My problem is the tabBarItem does not have the selected background when it loads. I have to tap on it to show the selected. I'm also using custom images for the tab bar items as well and have them being configured in each view that gets added to the tabBarController.
I'm using this to set the selected item:
_tabBarController.selectedViewController = [_tabBarController.viewControllers objectAtIndex:0];
The UITabBarItem gets created in each view that I add to the tabBarController:
-(UITabBarItem *)tabBarItem
{
return [[UITabBarItem alloc] initWithTitle:#"" image:[UIImage imageNamed:#"tab_select_indicator_map.png"] tag:0];
}
How can I also have the tabBarItem show the selected state?
Use following code of display selected tabBarItem when your tabBar is loaded.
[_tabBarController setSelectedIndex:0]; // your can set index as per your requirement.
Eited:
Make sure that you created your tabBarItem such like
UITabBarItem* myTestingItem = [[UITabBarItem alloc] init];
[myTestingItem setFinishedSelectedImage: [UIImage imageNamed: #"btnTabItem-SelectedImage.png"]
withFinishedUnselectedImage: [UIImage imageNamed: #"btnTabItem.png"]];
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
I want to create a Tab Application with a header image that is always present, no matter what Tab Item is active.
The example would be Foursquare:
I want to be able to place buttons and have different information displayed on that header.
Is that a simple Navigation Bar or something else?
Usually, for each tab is associated a viewController. You can notice it in the boilerplate which xcode creates when you choose "Tabbed Application".
Then, in each viewDidLoad or in the init of each viewcontroller you can set:
self.navigationItem.titleView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"image.png"]];
Then just change self.navigationItem.leftBarButtonItem and self.navigationItem.rightBarButtonItem with your controls on each viewController.
Edit:
In the appDelegate (in the didFinishLaunchingWithOptions method) you've to set something like this if you want use the navigationcontrollers:
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:#"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:#"SecondViewController" bundle:nil];
UINavigationController *myNav1=[[UINavigationController alloc] initWithRootViewController:viewController1];
UINavigationController *myNav2=[[UINavigationController alloc] initWithRootViewController:viewController2];
UIImage *navBackgroundImg = [UIImage imageNamed:#"bg_navBar.png"];
UIImage *tabBackgroundImg = [UIImage imageNamed:#"bg_tabBar.png"];
[myNav1.navigationBar setBackgroundImage:navBackgroundImg forBarMetrics:UIBarMetricsDefault];//iOS 5 only
[myNav2.navigationBar setBackgroundImage:navBackgroundImg forBarMetrics:UIBarMetricsDefault];//iOS 5 only
[[UITabBar appearance] setBackgroundImage:tabBackgroundImg];//iOS 5 only
self.tabBarController.viewControllers = [NSArray arrayWithObjects:myNav1, myNav2, nil];
self.window.rootViewController = self.tabBarController;
Looks like a simple navigation bar, but they aren't exactly simple. You need to place/create a NavigationItem on the bar (after placing/creating the bar itself) and then set the titleView to a custom view with your image. According to the documentation the left bar button (close in your first screen) has to be nil or else the titleView is ignored. Though you can place buttons in this custom view for left buttons.
I found out the easiest thing to do is to write:
- (void)viewDidLoad
{
[[UINavigationBar appearance] setBackgroundImage:
[UIImage imageNamed:#"UINavigationBar.png"] forBarMetrics:UIBarMetricsDefault];
}
At my MainViewController, and all Navigation bars that get created on each view controller gets configured like that.
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 am creating an iPhone app for iOS 4 using the newest SDK.
On one of my pages I would like the user to click a thumbnail of a photo and then a partial curl transition style take affect to show a full sized version of the image.
On the page with the full sized image I have a toolbar with a "Back" button and a "Select" button.
When I click the Back button the partial curls rolls back down to my first Xib.
BUT when I click the Select button, the app crashes.
Can anyone help me or explain why it is doing this? Thanks!
.m file:
-(IBAction)switchViews4 {
ImagePicker *image = [[ImagePicker alloc] initWithNibName:nil bundle:nil];
image.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:image animated:YES];
[image release];
}
Without seeing any other code, it is difficult to know why. But one guess is that you have a reference counting problem. Try:
-(IBAction)switchViews4 {
ImagePicker *image = [[[ImagePicker alloc] initWithNibName:nil bundle:nil] autorelease];
image.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:image animated:YES];
}
and see if it helps.