Reputation: 4479
I use the following code to add TTButton in my loadView method:
TTButton* button2 = [TTButton buttonWithStyle:@"forwardActionButton:" title:@"Login"];
[button2 setFrame:CGRectMake(245, 160, 65, 33)];
[self.view addSubview:button2];
But the button does not appear.
Do you know what am I missing here? (I did #import in my header file)
Thanks,
Upvotes: 0
Views: 681
Reputation: 5932
This code snippet looks fine. Where are you declaring the "forwardActionButton" style? It's not a three20 existing TTStyle as far as I know. Any custom styles should be in a style sheet class and should be loaded in the app delegate, as such:
[TTStyleSheet setGlobalStyleSheet:[[[StyleSheet alloc] init] autorelease]];
You can also try it with an existing TTStyle, such as "toolbarForwardButton:" and see if that's works.
Here's a working example on using TTButton and setting a function selector as the button's target:
TTButton* storyButton = [TTButton buttonWithStyle:@"toolbarRoundButton:" title:@"Open Full Story"];
storyButton.font = [UIFont boldSystemFontOfSize:18];
storyButton.frame = CGRectMake(100, 100, 200, 50);
[storyButton addTarget:self action:@selector(presentFullStory) forControlEvents:UIControlEventTouchUpInside];
[storyButton sizeToFit];
[self.view addSubview:storyButton];
Upvotes: 2