Three20 Launcher adding items help? - iPhone SDK - iphone

I am using the three20 launcher to get a homescreen feel in my app. I just implemented the basic launcher. I have two things that I want to accomplish.
First off, I would like the user to push a UIButton or whatever in a DIFFERENT view controller that the TTViewController and an item be added in the launcher, how would I do this?
Secondly I would like to know how you could do a view where the user could add all the information to add their own item in the launcher? This isn't as necessary as the first thing.
I would really like to know some of this and deepen my knowledge in the three20 launcher.

Just setup a way for your view controller to talk to the launcher, either by delegation, notifications or whatever you want, then add the item like this:
TTLauncherItem *item = [[TTLauncherItem alloc] initWithTitle:#"title"
image:#"http://imageURL"
URL:#"http://URL"
canDelete:YES];
[_launcherView addItem:item animated:YES];
[item release];

Related

Linking One View To Another Via A Button

I'm a bit new to programming for iOS, and I'm having some trouble linking one view to another via a button. I'm just creating a simple little app that does some calculations on a NSDate in an attempt to learn XCode and iOS programming.
I've already searched this quite a bit, and I've tried to learn from other examples but I'm having trouble getting the view to present, nothing happens when I press my button (which I've already checked to be linked to the button).
I've been having trouble understanding view programming, so please bear with me.
Here's my code for my button:
-(IBAction)resultsPressed
{
TimeResults *timeResults;
timeResults = [[TimeResults alloc] initWithNibName:#"TimeResults" bundle:nil];
[self.navigationController pushViewController:timeResults animated:YES];
[timeResults release];
}
TimeResults.xib is using a Navigation Controller if it matters, while my root view is simply a view. My thinking behind this was so that I could get the "back" button (though I'm not sure if this is the correct way tot do this, since they are not a part of the same hierarchy). Any suggestions on how this should be done would be greatly appreciated!
Nothing seems wrong with the code you posted, but you should have the Navigation Controller associated with the first nib, as the back button will display by default when a new view is pushed onto the stack.
Also, make sure that the Navigation Controller is set up properly in your AppDelegate. The proper way to do this can be seen if you start a new project and select "Navigation-based Application". If you use the new project as a sample to show you how to set up your old project correctly, you will have to make sure that the nib is set up correctly too. I would suggest using the new project, hooking it up as a UIViewController instead of a UITableViewController, and then moving your code from your old project to this new one.
Finally, make sure that you always import the .h file of the UIViewController you are going to push to. Hope that helps!
To load another view, try
AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
TimeResults *timeResults = [[TimeResults alloc] initWithNibName:#"TimeResults" bundle:nil];
[delegate.window setRootViewController:timeResults];
Hope it works. :)

Going back to list in Drill-Down Navigation Based Application using Core Data on iPhone

I want to build a simple drill down app (similar to the Contacts app on the iPhone). I am using Xcode 4.0.
I start by making a new "Navigation Based Application", and also say that I will be using Core Data for storage. I then go and add 'New File' and select UIViewController, and a subclass of UIViewController.
In my RootViewControler (which was made in the template) at didSelectRowAtIndexPath, I do the following:
NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
TrackerDetailViewController *trackerView = [[TrackerDetailViewController alloc] initWithNibName:#"TrackerDetailViewController" bundle:nil];
trackerView.title = [managedObject valueForKey:#"trackerName"];
trackerView.referringObject = managedObject;
[self.navigationController pushViewController:trackerView animated:YES];
[trackerView release];
And this works - I can load up some details in TrackerDetailViewController.
What I cant seem to figure out is how to go back! Most places I am reading online say that this should be happening automatically. I can't seem to get that to happen. If I download a few samples and compile them, they do have a back button - but I dont see how it was added or managed, and can't find what I am missing to not have it.
Check if [managedObject valueForKey:#"trackerName"] is actually returning anything. If not, then there's no title, and no back button will be created.
Oops, just re-read your code. It's the parent that needs a title assigned. Add something like self.title = #"myName; and myName should then appear as your back button in trackerView.

TabBar Application with a View that has a UIButton on the View to goto another View outside the TabBar

I'm new to iPhone development, and multiple views (xib or nib) are really confusing me. This is what i'm trying to achieve...
using TabBarControllerAppDelegate
Have 5 different TabBar Items and have created 5 different Views thru the TabBarController
The First View has a UIButton that is a Next button that needs to go to another view called View2.XIB.
I setup a new UIViewController which references the View2 and an IBAction for the switchPage, etc but not able to get it to do anything when clicking on the button.
All of My TabBar buttons work but not able to Navigate to anything outside of the Tabbar
Any help in this regard will be highly appreciated. Anyone have any examples
IBAction switchPageButtonPressed:(id)sender
{
[self.tabbarcontroller.tabBar setSelectedItem:[self.tabbarcontroller.tabBar.items objectAtIndex:1]];
here 1 means ur 2nd tabbar
}
It is difficult to find the problem without the code, but I will assume your action code for the switchPage button is incorrect. You should use code similar to the following:
- IBAction switchPageButtonPressed:(id)sender
{
ViewController2 *view2VC = [[ViewController2 alloc] initWithNibName:#"View2" bundle:nil];
[self presentModalViewController:nview2VC animated:YES];
[view2VC release];
}
If you are confident your method works, then you will want to verify that the action is hooked up correctly. The easiest way to do this is to place a breakpoint on the method and run the app in Debug. When you click the button, the debugger should break on your method, if it doesn't, you will need to check your connections in Interface Builder.

How to create a Main Menu that links to another view? (When developing iPhone Apps)

I'm a newbie programmer and I have played around with the SDK for a while. How do you create a homepage that has a button that will bring you to another view (the content of the app)??? If you know can you list the steps in order or link a tutorial site (It woul be awesome if the steps had code with it I needed). Thanks!
I would recommend getting a good book on iPhone programming. What you want to do is set up a UINavigationController, add the button to the first view, set the action of the button's touchUpInside to call the showContent method. Then implement the showContent method to push the Content view controller.
- (IBAction) showContent{
ContentViewController *myContentController = [[ContentViewController alloc] init];
myContentController.title = #"Content";
[self.navigationController pushViewController:myContentController animated:YES];
[myContentController release];
}
Have a read up on the documentation for pushViewController and UINavigationControllers, then follow this tutorial.

How can I add an additional "view" to my iphone app?

I have a simple iphone app that's based on the CrashLanding sample app. So basically you tap the title screen and do some stuff... all on the same "view". I want to add an "options" screen/page/view whatever with a few UISwitches. What's the easiest way to do this?
Cheers!
There are numerous examples that show how to manage multiple full-screen views -- each view should typically be managed by a separate view controller. Check the Xcode templates for an example of how you can set up a "flip" view.
Dunno if this will help I'm a bit new to objective-c and iPhone api.
Maybe u can do something like this:
Use the interface builder: just type "Interface Builder" on the Spotlight (top right corner) to generate like "myOptions.xib"
And then just implement it: like
#implementation myOptions
-(void)awakeFromNib
{
...
You can take a look at the QuartzDemo under the iPhone API to see how to load the interface list of objects. In the previous view controller you just need to add it to the object list.
It will look something like this:
#implementation previousController
-(void)awakeFromNib
{
menuList = [[NSMutableArray alloc] init];
QuartzViewController *controller;
controller = [[QuartzViewController alloc] initWithTitle:#"Options"];
controller.quartzViewDelegate = [[[myOptions alloc] init] autorelease];
[menuList addObject:controller];
[controller release];
Hope it helps
Use the Interface Builder to open MainWindow.xib. Add a new View to the XIB. Refer to the Interface Builder User Guide for more details.
http://developer.apple.com/documentation/DeveloperTools/InterfaceBuilder-date.html#doclist
While everyone has mentioned ways and pointers for displaying an additional view, if you are trying to solve your original problem of displaying application settings, you may want to use a settings bundle instead as per the Apple HIG for the iPhone
http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/MobileHIG/HandleTasks/chapter_6_section_4.html#//apple_ref/doc/uid/TP40006556-CH16-SW4
For how to do this, see this:
http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ApplicationSettings/chapter_12_section_1.html#//apple_ref/doc/uid/TP40007072-CH13-SW10