OGeek|极客世界-中国程序员成长平台

标题: ios - UILabel 在前一个值之上覆盖 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 19:58
标题: ios - UILabel 在前一个值之上覆盖

我设置了一个代码,其中 Viewcontroller *vcAppdelegate.mm 中全局声明,vc 初始化为 rootviewcontroller。当我从 Viewcontroller 调用更改 UILabel 的方法时,它会在 3-4 次更改后开始覆盖前一个文本。

//AppDelegate.mm

@implementation AppDelegate

ViewController *vc;

- (void)feedSamplesToEngineUInt32)audioDataBytesCapacity audioDatavoid *)audioData {
    if(check>0 || check==-1)
    {
      [vc writetolabel:check];
    }
}


- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions
{
    vc = (ViewController *)self.window.rootViewController;
}

..

//ViewcONTROLLER.m

@interface ViewController ()
{ AVAudioSession *session;
}

@end

@implementation ViewController 

@synthesize appDelegate; //global declaration bitches

- (void)viewDidLoad {
    [super viewDidLoad];

     appDelegate = (AudioRecorderAppDelegate *)[[UIApplication sharedApplication] delegate];

    self.TextView.text=@"OTP";
    [appDelegate startRecording];

}

- (void)writetolabelint) check{
    self.TextView.text=nil;

    if(check==-1)
        self.TextView.text= [NSString stringWithFormat"OTP not verified"];
    else
        self.TextView.text= [NSString stringWithFormat"%d", check];

}


- (void)dealloc {
    [UITextView release];
    [super dealloc];
}
@end

我尝试搜索相同的内容,但没有一个答案能解决我的问题。 这些值定期更改,问题不在于传递的值,而是在前 3-4 个值之后它们相互覆盖。



Best Answer-推荐答案


改变而不是

self.TextView.text = nil 

self.TextView.text=" "

关于ios - UILabel 在前一个值之上覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44778881/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4