Objective c 如何操作下一个/上一个键盘工具栏自定义iOS7

Objective c 如何操作下一个/上一个键盘工具栏自定义iOS7,objective-c,button,ios7,keyboard,Objective C,Button,Ios7,Keyboard,我正在尝试设置键盘工具栏上的“下一个/上一个”按钮,我希望进入导航以转到“下一个/上一个”文本字段。这就是我正在尝试的 如何使用系统栏按钮项更改为文本字段 -(void)addTeam{ UIView * view = [[UIView alloc]initWithFrame:CGRectMake(15, (0+(50*[teamsArray count])), 273, 50)]; [view setTag:[teamsArray count]+1];

我正在尝试设置键盘工具栏上的“下一个/上一个”按钮,我希望进入导航以转到“下一个/上一个”文本字段。这就是我正在尝试的

如何使用系统栏按钮项更改为文本字段

-(void)addTeam{
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(15, (0+(50*[teamsArray count])), 273, 50)];
        [view setTag:[teamsArray count]+1];

        UILabel *lblTeamName = [[UILabel alloc ] initWithFrame:CGRectMake(5,0,58,20)];
        [lblTeamName setBackgroundColor:[UIColor clearColor]];
        lblTeamName.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:(12.0)];
        lblTeamName.text = [NSString stringWithFormat:@"Team %i",[teamsArray count]+1];
        [lblTeamName setTag:7];
        [view addSubview:lblTeamName];

        UITextField* txtTeamName = [[UITextField alloc]initWithFrame:CGRectMake(5,20,150,30)];
        [txtTeamName setBorderStyle:UITextBorderStyleRoundedRect];
        [txtTeamName setPlaceholder:@"Team Name"];
        [txtTeamName addTarget:self action:@selector(hideKeyboard) forControlEvents:UIControlEventEditingDidEndOnExit];
        [txtTeamName setDelegate:self];
        [view addSubview:txtTeamName];

        UIButton *btnDelete = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [btnDelete addTarget:self
                      action:@selector(btnDelete_OnTouch:)
         forControlEvents:UIControlEventTouchDown];
        [btnDelete setTag:[teamsArray count]];
        [btnDelete setTitle:@"-" forState:UIControlStateNormal];
        btnDelete.frame = CGRectMake(160, 20, 20, 30);
        [view addSubview:btnDelete];

        [scrollView addSubview:view];
        [teamsArray addObject:view];

    }

    -(BOOL)textFieldShouldBeginEditing: (UITextField *)textField

    {
        UIToolbar * keyboardToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];

        keyboardToolBar.barStyle = UIBarStyleDefault;
        [keyboardToolBar setItems: [NSArray arrayWithObjects:
                                    [[UIBarButtonItem alloc]initWithTitle:@"Previous" style:UIBarButtonItemStyleBordered target:self action:@selector(previousTextField)],

                                    [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStyleBordered target:self action:@selector(nextTextField)],
                                    [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
                                    [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(resignKeyboard)],
                                    nil]];
        textField.inputAccessoryView = keyboardToolBar;

    }



    - (void)nextTextField {

        ????


    }

    -(void)previousTextField
    {

        ????

    }

您可以使用“下一步”和“上一步”按钮,

然后在ViewDidLoad中执行此操作

    UIToolbar * keyboardToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 40)];

    keyboardToolBar.barStyle = UIBarStyleDefault;
    [keyboardToolBar setItems: [NSArray arrayWithObjects:
                                [[UIBarButtonItem alloc]initWithTitle:@"Previous" style:UIBarButtonItemStyleBordered target:self action:@selector(previousTextField)],

                                [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStyleBordered target:self action:@selector(nextTextField)],
                                [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
                                [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(resignKeyboard)],
                                nil]];
    textField.inputAccessoryView = keyboardToolBar;