TT按钮未显示

发布于 2024-11-16 17:00:35 字数 322 浏览 3 评论 0原文

我使用以下代码在我的 loadView 方法中添加 TTButton:

TTButton* button2 = [TTButton buttonWithStyle:@"forwardActionButton:" title:@"Login"];
[button2 setFrame:CGRectMake(245, 160, 65, 33)];
[self.view addSubview:button2];

但按钮没有出现。

你知道我在这里缺少什么吗? (我在头文件中做了#import)

谢谢,

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,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见 2024-11-23 17:00:35

这段代码看起来不错。您在哪里声明“forwardActionButton”样式?据我所知,这不是一个现有的 Three20 TTStyle。任何自定义样式都应该位于样式表类中,并且应该加载到应用程序委托中,如下所示:

[TTStyleSheet setGlobalStyleSheet:[[[StyleSheet alloc] init] autorelease]];

您还可以使用现有的 TTStyle 进行尝试,例如“toolbarForwardButton:”,看看是否有效。

以下是使用 TTButton 并将功能选择器设置为按钮目标的工作示例:

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];

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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文