【发布时间】:2013-12-27 05:17:34
【问题描述】:
当键盘出现时如何在inputAccessoryView里面的UILabel中使用AutoScrollLabel。我似乎很难使用它,因为我没有使用 IB 方法将它连接到代码。我以编程方式执行此操作。我已经导入了 AutoScrollView 的 .h 文件,它给了我错误。 Find the AutoScrollLabel here
这是我的 inputAccessoryView 代码。
- (void)viewDidLoad
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake
(0, 0, 320, 23)];
label.backgroundColor = [UIColor clearColor];
label.shadowOffset = CGSizeMake(0, 1);
label.text = @"24 Hour time format only!";
label.font = [UIFont systemFontOfSize:17.0];
[label setTextColor:[UIColor whiteColor]];
UIBarButtonItem *text2 = [[UIBarButtonItem alloc] initWithCustomView:label];
UIToolbar* numberToolbar = [[UIToolbar alloc]init];
numberToolbar.barStyle = UIBarStyleBlackOpaque;
numberToolbar.items = [NSArray arrayWithObjects:text2, nil];
[numberToolbar sizeToFit];
【问题讨论】:
-
你能显示你的错误日志吗?
-
如果您访问上面的 GitHub 链接,您将看到使用部分。我尝试使用它并用 autoscrolllabel.whatever 替换它,但我无法运行模拟器,因为它说它无法识别 autoscrolllabel.whatever。这很奇怪,因为我在我的 .m 中导入了 autoscrolllabel.h。我已将两个自动滚动标签文件复制到我的项目中。
-
我已经尝试使用
AutoScrollLabelDemo,向其添加文本字段。这对我来说可以?我在textFieldDidBeginEditing:中添加了inputAccessoryView,并在textFieldDidEndEditing:中设置为nil。再试一次。如果你想要那个代码,我会发布它。 -
@Mani 如果可以,请给我看看您的代码。对不起,我是初学者。所有这些都是以编程方式完成的。 AutoscrollLabel 没有 IB。
标签: ios xcode uilabel inputaccessoryview