0
我加入UIToolBar我的UITextField失蹤UIToolBar:使用的UIScrollView
- (void)viewDidLoad {
[super viewDidLoad];
self.email.delegate = self;
self.password.delegate = self;
UIToolbar* toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 44)];
UIBarButtonItem* previous = [[UIBarButtonItem alloc] initWithTitle:@"Anterior" style:UIBarButtonItemStyleBordered target:self action:@selector(move:)];
UIBarButtonItem* next = [[UIBarButtonItem alloc] initWithTitle:@"Próximo" style:UIBarButtonItemStyleBordered target:self action:@selector(move:)];
UIBarButtonItem* space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:(UIBarButtonSystemItemFlexibleSpace) target:nil action:nil];
UIBarButtonItem* ok = [[UIBarButtonItem alloc] initWithTitle:@"Ok" style:UIBarButtonItemStyleBordered target:self action:@selector(ok:)];
[toolbar setItems:[[NSArray alloc] initWithObjects:previous, next, space, ok, nil]];
[toolbar setTranslucent:YES];
[toolbar setTintColor:[UIColor blackColor]];
for (UIView* view in self.view.subviews) {
if ([view isKindOfClass:[UITextField class]]) {
[(UITextField*)view setInputAccessoryView:toolbar];
}
}
}
現在我加入一個UIScrollView我的UIViewController和我UIToolBar已經不顯示。我錯過了什麼?我想我將工具欄添加到視圖而不是滾動視圖,並且因爲滾動視圖位於視圖上方,所以我看不到該工具欄。我該如何解決它?我需要添加滾動視圖來移動鍵盤後面的內容。