Using TTMessageController by -pushViewController - iphone

TTMessageController (from the Three20 framework) was recommended to me to replicate the email creation behavior. However, I am running into a bit of a problem integrating it with my application. The rest of my application uses a UINavigationController in order to show the various UIViewControllers, but it doesn't seem that TTMessageController works when called by -pushViewController. When I attempt to use pushViewController for a TTMessageController, the size of the view becomes smaller and the buttons on the navigation bar stop working. If anyone could give me any advice regarding how to show the TTMessageController correctly using this method, please let me know.
Thanks for any help!

You should present it modally, using presentModalViewController:animated:.

You should use also the TTNavigator component from the Three20 library.
For instance, basic navigationController doesnt not dispatch appear/disappear events ... so I assume Three20 components work better together !

Related

How to share a iAd adbanner across view's?

I am making a iPhone app, I am currently using iAd's in my view's. I've read something about apple recommending to share the adbanner's through out the view's. How can i do this because I have read the apple documentation and it was not clear enough and i was confused, please help me, if their are any tutorials please tell me or just answer and point me in the right way. Currently I have a ad for every view controller and it runs nice but it comes with a error: Too many active banners (10). Creation of new banners will be throttled.
Please help, i am using storyboards and the latest Xcode :) thanks
The way I do it is use a Singleton class that creates the adView, this way you only ever get 1 adView. Then in your viewDidAppear methods of all your ViewControllers you simply add the adView to your view.
You can see my code in the accepted answer here although that is for an AdWhirl ad view, it shouldn't be too difficult to change it for an iAd ad view.
This is the perfect case for a singleton. Many have simply made a subclass of ADBannerView, which can then be added to your view in -viewDidLoad (or -viewDidAppear with the proper precautions taken) and removed in -viewDidDisappear for each View Controller.

How to get/set the rootViewController?

Now,I gonna Develop an App ,which wants to switch from many different Views irregularly,also the views need to load large resources,AKA,it's hard to manage memory.Are there any good solustion?
PS:I created a ViewController as RootViewController,and When a button was Touch,run the code as
"ViewController=newController"
.The problem came,The new View loaded wrong way,it rotate so that couldn't show in a correct way.
I google for the solution,some one said ,I should replace the rootViewController,just like that,
[UIApplication sharedApplication].delegate.window.rootViewController=newController;
But I can't get/set the rootViewController in other class though it's a singleton.
Why not having a class that handles all the view switches ?
This article describes an architecture that might be helpfull: http://www.mikeziray.com/2010/01/27/handling-your-initial-view-controllers-for-iphone/comment-page-1/#comment-607

Point of Reference: Replacing the Root View Controller / App Delegate?

I'm new to iOS development, obviously, and I'm running into a bit of an issue with many of the tutorials that I find online. While I understand the majority of the code that is going into these programs, I cannot figure out how to translate this one fact, which is probably simple.
Many tutorials either use the Navigation-based template or View-based template, but I would like to try building tab bar applications. Tutorials either use the App Delegate or rootViewController (being the navigation controller), but since my tab bar is my rootViewController, I always run into an issue. I'm also unable to use the applicationDidFinishLaunching method in most of my code, because it technically only applies to the first tab at launch.
These are my questions:
Is there a way to "translate" these files into new classes (for example, creating an instance of NSObject for the App Delegate code for each individual tab or creating instances of UINavigationViewController)?
If I can create the instance of NSObject, how do I ensure that the code links up to the objects that I create in my viewController?
If I can create a file that uses UINavigationController, how do I trick the program into temporarily allowing the Nav Controller to be the rootViewController.
Many thanks in advance!
Right off the top of my head, I can only answer number 3 for you, you could do that in one of two ways that I am aware, and if anyone sees either of these is incorrect or bad practice, I hope someone corrects me, as this is what I have been doing.
[appDelegate.window addSubview:appDelegate.newRootViewController.view];
appDelegate.window.rootViewController = appDelegate.newRootViewController;
or
[self.navigationController pushViewController:appDelegate.newRootViewController animated:YES];
Both should accomplish the same thing, though if you can help it, the second version is ideal. Its also worth noting that for the first one, there is no tricking, you are actually setting the rootViewController of your app to something different.
I'll do some digging and see if I can answer any of your other questions for you too.
Edit: So after re-reading and thinking a bit more about it, I think the other two questions can be answered by maybe clarifying a tab bar application. Unfortunately, I'm fairly new to iOS as well, and I haven't had to opportunity to create a tab bar application, so I don't want to give you incorrect info. I would recommend checking out http://www.techotopia.com/index.php/Creating_an_iOS_4_iPhone_Multiview_Application_using_the_Tab_Bar_%28Xcode_4%29 and hopefully it can give you a little bit of a better idea of how Tab Bar Apps work. I've been using that eBook along with another from that site combined with Ray Wenderlich's tutorials to teach myself.
Anyways, I hope this helps to some extent, if you want me to try to clarify or go into detail on anything just comment and I'll see if I can help.
Good Luck!
-Karoly
You're misunderstanding how the app delegate works.
It's the delegate for the application, not a controller. Your controllers may be loaded from a xib by the time applicationDidFinishLaunching is called, but there's no connection between the two events.
applicationDidFinishLaunching is just the place where you do final setup before the app is ready for use.
If you don't instantiate your tab bar controller in your main xib file, you can instantiate it here, then instantiate all of it's controllers and add them to to the tab bar controller. While you're doing that, you can load plists, set properties on the controllers, etc.
If you do instantiate your tab bar controller in your main xib file, you can still get access to its controllers here. You can edit those controllers or throw them out and create new ones. You can even throw out your tab bar controller and switch to a navigation controller.
I can't answer questions 1 and 2 because the assumptions behind them are invalid.
Rather than ask how you work around perceived problems with the app delegate and tab bar controllers, describe what you're trying to accomplish.

First iPhone Multiview App - Some Guidance

I'm wanting to make a multiview app with 5-6 different screens and a data source to store user information. I've never made a multiview app before, and I have a good idea on how to start, but I'd like to hear some recommendations on "structuring" your app to properly support this.
A very simple analogy could be going about making a background color on a website... You could either use an image of a solid color or simply use the background-color style. Both get the job done, but using the style is a bit easier/more efficient.
I just want to make sure I'm starting off on the right foot. Should I keep all my functions in one class' .m/.h file? What's the best/efficient way to go about different screens?
Thanks, and I'll definitely try to help others out once I get a much better grasp on Objective-C and Xcode.
If you are new to the iPhone/iPad I highly recommend you check out the CS193P lectures, they are also avaliale on itunes. They give a good overview of iPhone programing and how things are done in Objective-C / Cocoa Touch. It will get anyone started in the right direction.
As to your specific question. Just start coding. In 6 months you'll realize eveything you wrote is cr*p and needs to be rewritten anyways, but doing it is the only way you'll realize what you wrote is cr*p so...
Some suggestions, specific to multi-viewed apps (which almost every app is) and I'm sure someone else can expand on this...
Learn (as much as possible) to code interactions between different views and viewcontrollers (vs using interface builder). The twitter app for example doesn't use Interface Builder at all.
If you use IB, don't dump everything into one .xib. Learn how to break them up. One .xib per viewcontroller should be it. I never use the IB UITabBarController or IB UINavigationController, those get initilized and used in code only.
Absolutly learn MVC (Model view controller).
The Apple documentation is often a good place to start for most things. Try here first. Hope this helps and good luck!
I used to use a UINavigationController. I created it as a singleton and accessed it statically so I could push and pop controllers easily (theres a reasonably good tutorial here). This is quite lightweight and theres enough documentation to get going with it quickly.
However the best approach I've used is the Three20 framework's TTNavigator. In a nutshell its a beefed up UINavigator that lets you push a new view onto the screen by calling an internal URL:
//(In your app delegate)
//Start up the navigator
TTNavigator* navigator = [TTNavigator navigator];
navigator.persistenceMode = TTNavigatorPersistenceModeTop;
//Map url's to controllers
TTURLMap* map = navigator.URLMap;
[map from:#"*" toViewController:[TTWebController class]];
[map from:#"ac://search" toViewController:[SearchViewController class]];
[map from:#"ac://results/(initToView:)" toViewController:[ResultsViewController class]];
Then to navigate to a controller:
[[TTNavigator navigator] openURLAction:[[TTURLAction actionWithURLPath:#"ac://results/searchResults/"] applyAnimated:YES]];
Whats also cool is that calling that #"ac://results/" the way we have above passes in the param #"searchResults" to the init method of the ResultsViewController ("initToView:") as we defined in the mapper
All the best!

How do I hide an infoButton in a utility app from the MainViewController when the infoButton is in the RootViewController?

How would I go about updating an object declared in the RootViewController from my MainViewController?
I'm attempting to hide my info button when my iAd is tapped, I have all the relevant pieces of code for the iAd in place, but can't figure out how to code the action. I saw an example of a similar situation online that was like this:
((MainViewController *)parentViewController).infoButton.hidden = #"";
I haven't been able to get that to work though, I just need this one value modifiable from the MVC, can anyone give me a simple suggestion?
P.S. I'm a total n00b and a snippet of code would help a great deal, I'm kind of learning as I go, thanks!
I figured this out through use of the NSNotificationCenter