[英]UITextField Alignment issue iOS 7
I am stuck in a very strange problem. 我陷入了一个非常奇怪的问题。 A default text field in iOS 8 & 7 behave very strange.
iOS 8和7中的默认文本字段的行为非常奇怪。 If the text box got focused the alignment of text get changed check the screen shots.
如果文本框对准焦点,则文本对齐方式将更改,请检查屏幕截图。
even with very small text size 即使文字很小
Edit: 编辑:
#import <UIKit/UIKit.h>
@interface LoginForm : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *txt_username;
@property (weak, nonatomic) IBOutlet UITextField *txt_password;
- (IBAction)loginButtonPressed:(id)sender;
@end
It should be a alignment issue. 这应该是对齐问题。 In your storyboard check the UITextField Alignment matches with the below image.
在情节提要中检查UITextField Alignment是否与下图匹配。
Try this. 尝试这个。 Its more of a work around, not exactly getting to the root of the problem but make your VC a UITextFieldDelegate, then make it the textFields delegate and use the following code.
它更多地是在变通,而不是完全解决问题的根源,而是使您的VC成为UITextFieldDelegate,然后使其成为textFields委托并使用以下代码。 -
--
(void)textFieldDidBeginEditing:(UITextField *)textField
{
// Change the alignment if you need to.
textField.textAlignment = NSTextAlignmentCenter;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.