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 6167171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:27:53+00:00 2026-05-23T22:27:53+00:00

I have a strange problem with a UITextField – I am setting the value

  • 0

I have a strange problem with a UITextField – I am setting the value of it to @”” (or anything else still causes it) and then shrinking the field with to zero. Next time I unshrink it, it displays the same value it had before I shrunk it, regardless of my having changed the text in the view. Typing in the field causes the glitch to go away, but it looks bad.

Image showing the problem

Complete code to reproduce:

throwaway_testViewController.h:

#import <UIKit/UIKit.h>

@interface throwaway_testViewController : UIViewController <UITextFieldDelegate>{



    UITextField * unitField;
}

@property (nonatomic, assign) IBOutlet UITextField * unitField;



-(IBAction)setEditingSectionUnits;
-(void)setEditingSectionValue;

-(IBAction)equalsPress;

@end

throwaway_testViewController.m

#import "throwaway_testViewController.h"

@implementation throwaway_testViewController

@synthesize unitField;

#pragma mark - Inputs

-(IBAction)equalsPress{
    [UIView animateWithDuration:0.5 animations:^(void){
        [unitField setText:@""];
        [self setEditingSectionValue];
    }];
}


#pragma mark Input Control

-(void)setEditingSectionUnits{
    [UIView animateWithDuration:0.5 animations:^(void){
        CGRect newRect = unitField.frame;
        newRect.size.width = 160;
        unitField.frame = newRect;
    }completion:^(BOOL completed){
        completed ? [unitField setNeedsDisplay] : nil;
    }];

    [unitField becomeFirstResponder];
}

-(void)setEditingSectionValue{
    [UIView animateWithDuration:0.5 animations:^(void){
        CGRect newRect = unitField.frame;
        newRect.size.width = [unitField.text sizeWithFont:unitField.font constrainedToSize:CGSizeMake(80, 250)].width;;
        unitField.frame = newRect;
    }completion:^(BOOL completed){
        completed ? [unitField setNeedsDisplay] : nil;
    }];

    [unitField resignFirstResponder];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [self setEditingSectionValue];
    return TRUE;
}

-(void)textFieldDidBeginEditing:(UITextField *)textField{
    [self setEditingSectionUnits];
}


@end

In the xib, place a UITextField tied to unitField, and set the delegate of the text field to be file’s owner.

Place a UIButton labeled equalsPress and tie it to that IBAction, and another called edit, tied to setEditingSectionUnits. To see the bug reproduced:

  • Run the app
  • Press edit
  • type something into the text field (min 8-10 characters)
  • press enter on the keyboard
  • press equalsPress
  • press edit
  • Should see: cursor and empty text field
  • Actually see: whatever you typed last, with a cursor at the start.
  • Typing makes this text disappear.
  • 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-05-23T22:27:54+00:00Added an answer on May 23, 2026 at 10:27 pm

    after replicating your code, i found that the problem you mentioned occurs only if you press return on the keyboard and then tap the equals press button…
    resigning first responder before calling animation block in your setEditingSectionValue method resolved the problem:

    -(void)setEditingSectionValue{
        [unitField resignFirstResponder];
        [UIView animateWithDuration:0.5 animations:^(void){
            CGRect newRect = unitField.frame;
            newRect.size.width = [unitField.text sizeWithFont:unitField.font constrainedToSize:CGSizeMake(80, 500)].width;;
            unitField.frame = newRect;
        }completion:^(BOOL completed){
            completed ? [unitField setNeedsDisplay] : nil;
        }];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange problem with UITableView and UITextField inside the cell (as subview).
I have strange problem. I have own remote repository and upload their plugin. Then
I have strange problem. When I use @return Model\Article in the model-loading method then
I have strange problem with sharepoint and ajax functionality. We have an UpdatePanel placed
i have strange problem doing reporting: i have numerous clients with different issued invoices.
We have very strange problem, one of our applications is continually querying server by
I have a strange problem with mod_rewrite, the rules that are relevant here are:
I have a strange problem with VS2008. My solution has 8 projects (all c#)
I have a strange problem with lxml when using the deployed version of my
I have a strange problem that is only happening in a single location. I

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.