如何将UILabel的文本从一侧移到另一侧并重复自身。 UILabel位于UIToolbar内,它是工具栏的“inputAccessoryView”。我还有另一个问题是如何将多个项目作为某事物的自我。查看我的代码,您将看到我将“cell1Field1Dismiss”作为输入inputAccessoryView的self。
为了进一步说明,我有一个带有大约10个UITextFields的viewController和另外10个UITextFields来重新签名第一个响应者。
- (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];
//UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
//UIBarButtonItem *flexibleSpace2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIToolbar* numberToolbar = [[UIToolbar alloc]init];
numberToolbar.barStyle = UIBarStyleBlackOpaque;
numberToolbar.items = [NSArray arrayWithObjects:text2, nil];
[numberToolbar sizeToFit];
self.cell1Field1Dismiss.inputAccessoryView = numberToolbar;
}
辞职第一响应者的IBAction是:
- (IBAction)hideKeyboard:(id)Sender
{
[cell1Field1Dismiss resignFirstResponder];
[cell1Field1 resignFirstResponder];
[cell1Field2Dismiss resignFirstResponder];
[cell1Field2 resignFirstResponder];
[cell2Field1Dismiss resignFirstResponder];
[cell2Field1 resignFirstResponder];
[cell2Field2Dismiss resignFirstResponder];
[cell2Field2 resignFirstResponder];
[cell3Field1Dismiss resignFirstResponder];
[cell3Field1 resignFirstResponder];
[cell3Field2Dismiss resignFirstResponder];
[cell3Field2 resignFirstResponder];
[cell4Field1Dismiss resignFirstResponder];
[cell4Field1 resignFirstResponder];
[cell4Field2Dismiss resignFirstResponder];
[cell4Field2 resignFirstResponder];
[cell5Field1Dismiss resignFirstResponder];
[cell5Field1 resignFirstResponder];
[cell5Field2Dismiss resignFirstResponder];
[cell5Field2 resignFirstResponder];
}
转到此图片以查看提到的视图控制器。 http://i.stack.imgur.com/UVVpi.png
答案 0 :(得分:0)
对于Resigning KeyBoard,您可以使用
[self.view endEditing:YES] remove all the resignFirstResponders.
找到Marquee标签here
的解决方案