UITextField drawTextInRect永远不会被调用
我已经安装了iOS11 beta5并捕获了一些问题。我为我的自定义UITextField重写drawTextInRect
方法,但它永远不会被调用。UITextField drawTextInRect永远不会被调用
注意:是的,我已经看到this的答案,但它在10.3上正常工作。
代码示例重现该行为:
#import <UIKit/UIKit.h>
@interface MYCustomTextField : UITextField
@end
@implementation MYCustomTextField
-(void)drawTextInRect:(CGRect)rect {
[super drawTextInRect:rect];
NSLog(@"drawTextInRect calling");
}
@end
我也对苹果的开发者论坛上创建了一个new thread。
drawTextInRect永远不会调用UITextField。你必须为此使用UILabel。
那么为什么它在iOS 10.3上使用xcode8? @swapnil patel –
drawTextInRect/drawText(in :)应该在UITextField上工作。 Apple在文档中提到了这个功能(https://developer.apple.com/documentation/uikit/uitextfield/1619587- drawtext?changes = lastst_minor)。我有完全相同的问题,在Xcode 8/iOS 10中工作,在Xcode 9/iOS 11中不起作用。正在调用draw(_ rect:CGRect)函数,但它仍然在那。 –
@ChristopherHannah drawRect实际上并不相同。它仅召唤我一次,并且在辞职后不重画。 –
可能的重复https://*.com/questions/1920783/drawtextinrect-on-uitextfield-not-called – danh
[drawTextInRect on UITextField not called]可能重复(https://*.com/questions/1920783)/drawtextinrect-on-uitextfield-not-called) –
我已经说过它可以在iOS 10.3上使用xCode 8正确工作。 –