Three20 TTLauncherItem in a custom position - iphone

When I add a new TTLauncherItem icon to a TTLauncherView, this icon is set at the last position. Could I set it in another position? How should I do it?

Subclass TTLauncherView and override...
- (void)addItem:(TTLauncherItem*)item animated:(BOOL)animated;
If you look at that method in TTLauncherView, you can see how it's getting the page to add to by using...
NSMutableArray* page = [self pageWithFreeSpace:self.currentPageIndex];
So instead of doing that you can pick the first page or whatever. Once you have the page you want to add to you can put the item wherever you want. Page is just an NSMutableArray of TTLauncherItems.

Related

Three20 TTLauncherView showing by default the first page of a menu

When I add some icons (50) to the TTLauncherView Three20 view, TTLauncherView is always in the last page of the pages of icons. How can I change it to always show the first page of icons instead of the last one?
Thanks.
Update
in the viewDidLoad method, I call this one:
- (void)loadIcons
{
int first=0;
TTLauncherItem *firstIcon;
for (NSString *nombre in nombres) {
TTLauncherItem *icono=[self generarIcono:nombre];
[launcherView addItem:icono animated:YES];
if(first==0)
firstIcon=icono;
first=1;
}
[self.view addSubview:launcherView];
if (firstIcon!=nil) {
[launcherView scrollToItem:firstIcon animated:NO];
}
}
After adding your icons juste call [launcherView scrollToItem:item1 animated:NO]
You are adding all the items animated. I don't think that is what you want during viewDidLoad and on the other hand, this is what keeps your code from working like you expected. You are adding items animated and then request an immediate (not animated) move to the fist items. That clashes. The simplest thing to do is to add the items without animation [launcherView addItem:icono animated:NO];
But that is not the way you would normally add a lot of items to the launcher. It creates a lot of overhead. There's a pages property, that is better suited for your needs. Look a the TTCatalog example app for code.

Adding a value to a bundle in ios

I was wondering how I can add an int to a bundle and pass it to the next view that I am calling.
What I am trying to do is click an item on a UITableView and that will call the next .m file and pass the int that pertains to a document that I will be looking up online. This document has a specific id and without passing it to the next view I will not be able to get the list that I need to compile and show on the next UITableView.
How are you displaying the next view? Can you not just add an instance variable to the view to be called?
View2 *view = [[View2 alloc] init]];
[view setSpecificId:myId];
display the view....

How to "transfer" UIImageView between view

when you click "Share" in my app you'll show an ActionSheet like this:
Take photo
Select photo from Library
Cancel
You tap "Take photo" and you'll see an ImagePicker, with "presentModalViewController".
You take a photo and you select "OK" in the ImagePicker.
Here, I want the photo just taken in a new view with other label. Like this:
(new view)
Little photo (just taken)
- Label 1 (ex. Title of photo)
- Label 2 (ex. Location of photo)
and a button "Share" for sharing your photo and its infos.
How can I do this? I'm stopped after take the photo. How can I send my photo (in a imageview) to another view?
Thanks
for this,
make some global varible in appDelegate class and make them property.
for saving Image make UIImage object in app delegate and for title and path make string variables and make all these : property then.
then when you select image from modelView at the selection time you must set app delegate properties(image,title,path).and navigate to other page and on viewWillAppear of new page
set your controls (ImageView and labels) by these objects.
I hope, it helps you. You need to code this logic.
Some one already suggested for that by using appDelegate.
you can do in other way too.
just declare some variable like imagePath and imageTitle in the 2nd view controller. and set property to them like
#property (nonatomic,retain) NSString *imagePath;
And then in the 1st view controller access those variables like
secondViewControllerObj.imagePath = #"Give Image Path Here";
then you can access the imagePath in the 2nd View Controller as self.imagePath
Regards,
Satya

add to favorites button help

how would an add to favorites button work in order to take the controller selected and add it to a tab bar item,
i tried using an ibaction to add an entry to an array however i wasnt sure on how to handle this problem.
i would like to add a uibutton that adds an entry to this kind of array format
rootArray = [[NSArray alloc] initWithObjects:#"entry1", #"entry2", nil];
the tab bar would have two views on the favorite table view and one with all the rest of the cells. i would like to click on the "normal" table view which would take me to the detailview controller already implemented. Afterwards i would like to have a button on the detailviewcontroller that would say something like add to favorites and add this detailview and its cell to the favorites tab controller. i would like to add the uibutton to add the detailview controller in the mentioned format above however im not sure how to do this.
i would appreciate some help in pointing me in the right direction thanks
Am assuming u have a database somewhere from where you are getting data for your "normal" tableview. What you need to do is you could add a favorites table or just add a "is_favorite" field to your table.I'd go with the latter option.
With this in place you just have to filter your results. Records with "is_favorite" as true added to the favorites table view while everything (both favorite and non-favorite) appear in the other table view.
For the details view, you could have a UIBarButton for adding to favorites. The iphone sdk already has a system button for that. Add the following to you viewDidLoad:
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:#selector(addToFavorites:)];
then add a method called addToFavorites to your detailviewcontroller class. This will respond to the IBAction. Inside addToFavorites add some code that will set the is_favorite field to true.
I believe all this covers how you could accomplish your task.
Edit: The explanation above was based on the assumption you were using a database.
Update
Since you are storing everything in an array here's what you could do.
Define the favorites (mutable)array in you YourAppDelegate.h file as you would any normal property.
NSMutableArray *favorites;
Then inside the addToFavorites do something like:
YourAppDelegate *app = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
[app.favorites addObject:current_detail]; //add whatever detail you selected
favorites is the array you will be using as the source of data for your favorites table view.
Hope all this makes sense now.

How to change the color of UIBarButtonItem?

I have a UIToolbar, and then add two UIBarButtonItem to items of UIToolbar. How can I change the color of UIBarButtomItem? I did't find a API in the document.
see "Changing colors of UINavigationBarButtons"
EDIT: I remove the link because the domain is down...
The is the text from google cache:
Alright, here’s another quick tip. “How to change the colors of a button on a toolbar.” Of course, this can be applied to any toolbar but I am going to demonstrate the procedure on a UINavigationBar.
The above image only shows a couple of colors. In truth, you can make the button any color that you want. Fantastic! The code is really simple to do this as well. The first thing that we want to do is open the header file for whichever object will be turning a nav bar button a different color and declare the forward class UINavigationButton. You can get this class by either iterating through the subviews of the UINavigationBar, reading its subviews class names, or by class-dumping UIKit if you have a jailbroken device.
Place the following line before your interface declaration:
#class UINavigationButton;
Now, declare a new method in the header that we will use to actually change the button’s color.
- (void)changeNavigationButtonColorToColor:(UIColor *)newColor
Or something similar to the above line of code.
Now, open up your object’s implementation file and implement the above method. Anywhere in your file, add the following method:
- (void)changeNavigationButtonColorToColor:(UIColor *)newColor {
for (UIView *view in self.navigationController.navigationBar.subviews) {
NSLog(#"%#", [[view class] description]);
if ([[[view class] description] isEqualToString:#"UINavigationButton"]) {
[(UINavigationButton *)view setTintColor:newColor];
}
}
}
As you can see above, this is actually a lot easier than it first appears to be. What we first do is set up a for loop to iterate through the subviews of the UINavigationBar using NSFastEnumeration. We then output the class name of the subview, for future reference. IF the class name is UINavigationButton, then we’ve got our view. All we do is set the tintColor property if the UINavigationButton.
That’s it, we’re done!
Alternatively, if you want a wider scope, I’d suggest creating a new UINavigationBar category and placing the button color changing method in there. This was your method can be performed by any class that uses a UINavigationBar without having to recreate the same method over and over.
Remember, a back button and a navigation button are not the same thing. You will have to color the back button separately.
And as usual, here’s a link to a sample app that demonstrates this code: NavButtonColor.zip
UIBarButtomItem has limitation in customization so you can use UIButton in place of UIBarButtonItem it will gives you more customization.
For a solution that doesn't use a private API.
You can fake it by making a UISegmentedControl look like a UIBarButtonItem.
http://fredandrandall.com/blog/2011/03/31/how-to-change-the-color-of-a-uibarbuttonitem/