After relaunch, application hides navigation bar in three20 - three20

i've got a small problem:
i've written a small project which is using tabBarController, implementation file have only this methood:
- (void)viewDidLoad {
[self setTabURLs:[NSArray arrayWithObjects:
#"tt://tableWithShadow",
#"tt://launcher",
#"tt://characterList",
#"tt://mapViewController",
nil]];
}
in appDidFinishLaunching in my appDelegate, tab bar is mapped like this:
[map from:#"tt://tabBarCon" toSharedViewController:[TabBarController class]];
the problem is when app quits, and then reopen again, it don't fully remember the state before quiting, the navigationBar is hidden and no viewController is picked on tabBar, it looks like this:
http://dl.dropbox.com/u/8583302/Zrzut%20ekranu%202010-10-13%20%28godz.%2015.17.11%29.png
but it should be like this:
in next post
does anybody seen this and know the way to fix it?

You probably need to specify the parent property for your view controllers as follows:
[map from:#"tt://tableWithShadow"
parent:#"tt://tabBarCon"
toViewController:[TableWithShadowViewController class]
selector: nil
transition: 0];

I had same problem as yours. I assume you have four mapping urls at your AppDelegate. After read this post (http://groups.google.com/group/three20/browse_thread/thread/ec022b9aaa39f366/) and changed to toSharedViewController from toViewController, the navigation bar shows up after relaunch.
[map from:#"tt://tableWithShadow" toSharedViewController:[TableWithShadowController class]];
[map from:#"tt://launcher" toSharedViewController:[LauncherController class]];
[map from:#"tt://characterList" toSharedViewController:[CharacterListController class]];
[map from:#"tt://mapViewController" toSharedViewController:[MapViewControllerController class]];

Related

Xcode close view controller

I have two viewControllers parent and child, from parent I'm opening child viewController like this:
ClildVC *modal = [[ClildVC alloc] initWithNibName:nil bundle:nil];
modal.modalPresentationStyle = UIModalPresentationPageSheet;
[self presentModalViewController:modal animated:YES];
and when I return from child View to parent, I use this:
[self dismissModalViewControllerAnimated:YES];
I want, when returning to parent viewController it be refreshed (reloaded), like I open it first time.
in your parentViewController in .h and .m add method
- (void)refreshData
{
//refresh your data
}
in your childViewController type this
- (IBAction)backToParent
{
YourParentController *parent = (YourParentController *)self.parentViewController;
[parent refreshData];
[self dismissModalViewControllerAnimated:YES];
}
dismissModalViewControllerAnimated: is deprecated as of iOS6
You should use dismissViewControllerAnimated:completion: which was introduced in iOS5 in the child view controller after calling a data update on its parent view controller
You are initiating with no nib file and no bundle identifier.
So its looking for a non existent nib in a bundle that isn't there
either design the nib in IB (xcode 4) or storyboard (4.2 +) or programatically by using the designated initialiser for the modal view controller.

Where do I put the code for changing the nav bar color in xcode 4.3

Ok, it's 3 am atm and I haven't a clue where I put this:
[navigationController.navigationBar setTintColor:[UIColor redColor];
If you would please post the whole .m/.h files that would be great. Also, do I connect anything using segues or outlets? And when you create the .h/.m files do I need UINavigationController or similar selected or just the normal UIViewController? Thanks.
Update: Nevermind I got it, thanks though. Below is the code for others having my issue.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UINavigationBar *bar = [self.navigationController navigationBar];
[bar setTintColor:[UIColor lightGrayColor]];
}
Basically just add on to what's already there.
I feel stupid lol.
You can set that value right after you init your UINavigationController, i.e:
UINavigationController *controller = [[UINabvigationController alloc] initWithRoot...
[controller.navigationBar setTintColor:[UIColor redColor]];

Dynamic object creation

I did created NSTableView, but this not displays on NSWindow. Code example:
NSTableView *tbl = [[NSTableView alloc] initWithFrame:NSMakeRect(0,0,500,500)];
[window.contentView addSubview:tbl];
P.S.
I need make application without IBOutlets only
That code is correct. Make sure that you have created or loaded the window (i.e., window is not nil) and that you have given it a content view (window.contentView is not nil).
Also, don't forget to release tbl.
Try:
NSTableView *tbl = [[NSTableView alloc] initWithFrame:NSMakeRect(0,0,500,500)];
[window setContentView:tbl];
[tbl release];
Assuming your window object isn't nil and that you've initialized it correctly.
Update: see here for info about making an NSWindow visible; specifically:
Opening a window—that is, making a window visible—is normally accomplished by placing the window into the application's window list by invoking one of the methods makeKeyAndOrderFront:, orderFront:
So, after the code above, added the following to make the window visible:
[window makeKeyAndOrderFront:self];
why don't you use uitableview?
it is standard class for table view.
UITableView *tbl = [[[UITableView alloc] initWithFrame:NSMakeRect(0,0,500,500)] autorelease];
[window.contentView addSubview:tbl];
[window makeKeyAndVisible];

Loading NSView from NIB won't work

I have this code to load an NSView from a NIB and add it to another NSView:
// INIT
- (void)awakeFromNib {
// Load nib
DNListViewController *listViewController = [[DNListViewController alloc] initWithNibName:#"ListView" bundle:nil];
// Add view to window
[listViewController.view setFrame:detailView.frame];
[detailView addSubview:listViewController.view];
// MEM
[listViewController release];
}
All outlets are connected right, but nothing shows up. I don't understand why! Can someone help me? Thanks.
This is about NSViews, not UIViews!
Oh, I fixed it already. Nevermind, I'll let is stay here for people from the future.
[listViewController.view setFrame:detailView.frame];
must be
[listViewController.view setFrame:detailView.bounds];

TTNavigator not opening URLs when clicking on links in TTStyledTextLabels

Trying to make a simple link clicking activity work. I think I understand TTNavigator and TTStyledLabel, but can't get it to work.
Code:
#interface SomeVc : UIViewController <TTNavigatorDelegate> {
IBOutlet TTStyledTextLabel *styledTextLabel;
}
#end
#implementation SomeVc
- (void)viewDidLoad {
[super viewDidLoad];
navigator = [TTNavigator navigator];
navigator.persistenceMode = TTNavigatorPersistenceModeNone;
navigator.delegate = self;
TTURLMap* map = navigator.URLMap;
[map from:#"*" toViewController:[TTWebController class]];
styledTextLabel.text = [TTStyledText textWithURLs:someText];
[navigator openURLAction:[TTURLAction actionWithURLPath:#"http://www.cnn.com/"]];
}
- (BOOL)navigator: (TTNavigator*)navigator shouldOpenURL: (NSURL*)URL {
NSLog(#"trying to open %#", [URL absoluteString]);
return NO;
}
#end
I.e inside a viewcontroller, get the navigator and set self to be its delegate. When a link is opened, the shouldOpenURL delgate method gets called, where I will handle the URL opening myself. (I plan to let navigator handle more of it, but want to get this simple case working first.)
I have a test call at the end of viewDidLoad: which fires the delegate method fine.
Problem: I see the styledTextLabels rendered fine with URL-s, but when I tap on those, nothing happens. They don't reach the TTNavigator for some reason and I can't understand why. Feels like I'm missing some simple connection/scaffolding somewhere, but can't figure it out.
How to make it so that the links tapped in the styledtextlabel will reach the navigator delegate? Or how else should I implement this simple case with styledtextlabel? (just want to get callbacks for url taps.)
try setting the window property :
TTNavigator* navigator = [TTNavigator navigator];
navigator.window = window;
If you don't have one you can add one
navigator.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]
You might also need:
[navigator.window makeKeyAndVisible];

Resources