Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9013529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:17:29+00:00 2026-06-16T03:17:29+00:00

After a some time, searching here for some solutions we found this post: How

  • 0

After a some time, searching here for some solutions we found this post:

How to navigate through textfields (Next / Done Buttons)

We tried that but unfortunately it doesn’t work at all. Note that we put the UITextFields inside a UITableView.

We think the problem is around the Delegates but we don’t know how to deal with it. Following i show you our code:

.h:

#import <UIKit/UIKit.h>

@interface LoginViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate> {

    UITableView *loginTableView;
    UITextField *textField;

}

@property UITableView *loginTableView;
@property UITextField *textField;
@property UIButton *loginButton;
@property UIButton *cancelButton;

@end

.m:

#import <QuartzCore/QuartzCore.h>
#import "LoginViewController.h"
#import "RootViewController.h"

@interface LoginViewController ()

@end

@implementation LoginViewController

@synthesize loginTableView, textField, loginButton, cancelButton;

- (void)viewDidLoad {

    [super viewDidLoad];

    // Make rounded corners view
    [self.view.layer setCornerRadius:4.0];
    [self.view.layer setMasksToBounds:YES];
    self.view.layer.opaque = NO;
    self.view.backgroundColor = [UIColor whiteColor];

    // Create background image view
    UIImageView *loginBackgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height+20)];
    // Create background's image
    UIImage *backgroundImage = [UIImage imageNamed:@"loginbackground.png"];
    loginBackgroundImageView.image = backgroundImage;
    [self.view addSubview:loginBackgroundImageView];

    // Create logo's image
    UIImage *logoImage = [UIImage imageNamed:@"logo.png"];

    // Create logo's image view
    UIImageView *logoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width/2 - logoImage.size.width/2, self.view.bounds.size.height/9, logoImage.size.width, logoImage.size.height)];

    // Set image to logo's image view
    logoImageView.image = logoImage;

    [self.view addSubview:logoImageView];

    // Create login table view
    loginTableView = [[UITableView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width/2 - (self.view.bounds.size.width/1.2)/2, self.view.bounds.size.height/3, self.view.bounds.size.width/1.25, 100) style:UITableViewStylePlain
                      ];
    loginTableView.delegate = self;
    loginTableView.dataSource = self;

    // Create login container table view
    UIImage *containerImage = [UIImage imageNamed:@"loginform.png"];
    UIImageView *containerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width/2 - containerImage.size.width/2, self.view.bounds.size.height/3, containerImage.size.width, containerImage.size.height)];
    containerImageView.image = containerImage;
    [self.view addSubview:containerImageView];

    // Custom table view
    loginTableView.backgroundColor = [UIColor clearColor];
    loginTableView.separatorColor = [UIColor clearColor];

    // Disable scroll
    loginTableView.scrollEnabled = NO;

    // Add login table view to main view
    [self.view addSubview:loginTableView];

    // Create buttons images
    UIImage *loginImage = [UIImage imageNamed:@"loginbtn2.png"];
    UIImage *cancelImage = [UIImage imageNamed:@"cancelbtn.png"];

    // Create buttons
    loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];

    // Set buttons' normal state image
    [loginButton setImage:loginImage forState:UIControlStateNormal];
    [cancelButton setImage:cancelImage forState:UIControlStateNormal];

    // Place buttons
    loginButton.frame= CGRectMake((self.view.bounds.size.width/2)-(loginImage.size.width/2), self.view.bounds.size.height/1.65, loginImage.size.width, loginImage.size.height);
    cancelButton.frame= CGRectMake((self.view.bounds.size.width/2)-(cancelImage.size.width/2), self.view.bounds.size.height/1.375, cancelImage.size.width, cancelImage.size.height);

    // Set buttons' action
    [loginButton addTarget:self action:@selector(loginButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [cancelButton addTarget:self action:@selector(cancelButtonPressed:) forControlEvents:UIControlEventTouchUpInside];

    // Set button to the main view
    [self.view addSubview:loginButton];
    [self.view addSubview:cancelButton];

}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 2;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
        cell.accessoryType = UITableViewCellAccessoryNone;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        if ([indexPath section] == 0) {
            textField = [[UITextField alloc] initWithFrame:CGRectMake(50, 11, 200, 25)];
            textField.adjustsFontSizeToFitWidth = NO;
            textField.textColor = [UIColor darkGrayColor];
            textField.backgroundColor = [UIColor clearColor];
            if ([indexPath row] == 0) {
                textField.placeholder = @"Username";
                textField.keyboardType = UIKeyboardTypeEmailAddress;
                textField.returnKeyType = UIReturnKeyNext;
                textField.autocorrectionType = UITextAutocorrectionTypeNo;
                textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
                textField.tag = 0;
            }
            else {
                textField.placeholder = @"Password";
                textField.keyboardType = UIKeyboardTypeEmailAddress;
                textField.returnKeyType = UIReturnKeyDone;
                textField.autocorrectionType = UITextAutocorrectionTypeNo;
                textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
                textField.secureTextEntry = YES;
                textField.tag = 1;
            }
            textField.clearButtonMode = UITextFieldViewModeAlways;
            textField.delegate = self;
            [textField setEnabled: YES];
            [cell addSubview:textField];
        }
    }
    if ([indexPath section] == 0) { // Email & Password Section
        if ([indexPath row] == 0) { // Email
            cell.imageView.image = [UIImage imageNamed:@"usernameico.png"];
        }
        else {
            cell.imageView.image = [UIImage imageNamed:@"passwordico.png"];
        }
    }
    else { // Login button section
        cell.textLabel.text = @"Log in";
    }
    return cell;    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *) tableView {
    return 1;
}

-(BOOL)textFieldShouldReturn:(UITextField*) formTextField {
    NSInteger nextTag = formTextField.tag + 1;
    // Try to find next responder
    UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
    if (nextResponder) {
        // Found next responder, so set it.
        [nextResponder becomeFirstResponder];
    } else {
        // Not found, so remove keyboard.
        [formTextField resignFirstResponder];
    }
    return NO; // We do not want UITextField to insert line-breaks.
}

- (void)loginButtonPressed: (UIButton *) sender {

}

- (void)cancelButtonPressed: (UIButton *) sender {

}

@end

Thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:17:30+00:00Added an answer on June 16, 2026 at 3:17 am

    The problem is the table. When you ask you text view for it’s superview, it will return the cell, which doesn’t contain any other siblings. Try:

    UIResponder* nextResponder = [tableView viewWithTag:nextTag];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here I need to call a javascript function first and after some time I
after several attempts and some searching I finally decided to try it here. Short
Hello all! This is my first post on stackoverflow. After hours of searching and
thanks for your time first...after all the searching on google, github and here, and
I've spent some time searching for this answer on SO, but couldn't find it,
I have been googling and searching to resolve this error for some time and
After some time researching and trying different things I still cannot get my @ExceptionHandler
I am getting after some time unrecognized selector sent to instance exception. When i
Possible Duplicate: how to hide a div after some time period? i need to
I have my java-written application being killed after some time of work. Java application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.