2

It's my first post, when i have a problem i always find the solution here, but now i'm really stuck.

I think that I've read all the posts related to this problem, but with no luck.

I have a table view controller which contains multiple custom cells, every cell have a textfield input inside. So the user start from the top, insert the first value, then hit "Apply" button on the keyboards custom toolbar, taking control of the next textbox.

The toolbar is showing but not working at the moment, but doesn't matter, because when i press enter on simulator, the next textbox becomes active.

The real problem is about the view that isn't scrolling! It scrolls when i select the firts textbox, then nothing.

I've searched everywhere, and unfortunately i'm working a lot and i don't have enough time to solve this problem by myself.

Maybe it's a stupid thing that i'm missing, i hope someone can help.

in the .h file :

@interface PaginaCalcoliController : UITableViewController <UITextFieldDelegate> 

every textbox is delegated to PaginaCalcoliController which is the view class.

I'm sorry for my english, i hope we can find a solution!

4

2 回答 2

1

对动画时间进行硬编码不是一个好主意。0.25 是键盘的默认值。更好地获得如下值:

 NSNumber *rate = notification.userInfo[UIKeyboardAnimationDurationUserInfoKey];
于 2015-01-09T03:45:35.293 回答
1

我认为,要做到这一点是通过设置“contentInset”。首先用 UIViewController 替换你的 UITableviewController 并将 UITableview 添加为子视图,然后连接 tableview、数据源和委托,然后这样做,把它放在视图 didload 方法中。

-(void)viewDidLoad
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) 
                                                 name:UIKeyboardDidShowNotification object:nil]; 
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardDidDisappear:) name:UIKeyboardDidHideNotification object:nil];

}

-(void)keyboardDidShow:(NSNotification *)notification
{

    NSDictionary *info=[notification userInfo];
    NSValue *aValue=[info objectForKey:UIKeyboardFrameEndUserInfoKey];

    CGRect keyBoardRect=[aValue CGRectValue];
    keyBoardRect=[self.view convertRect:keyBoardRect fromView:nil];
    CGFloat keyBoardTop=keyBoardRect.origin.y;

    tableView.contentInset=UIEdgeInsetsMake(0, 0, keyBoardTop+50, 0);
}

-(void)keyboardDidDisappear:(NSNotification *)notification
{
 tableView.contentInset=UIEdgeInsetsMake(10, 0, 10, 0);


}

希望这会有所帮助... :)

于 2013-06-17T06:24:14.573 回答