gpt4 book ai didi

ios - UILabel 覆盖之前的值

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:09:40 25 4
gpt4 key购买 nike

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

//AppDelegate.mm

@implementation AppDelegate

ViewController *vc;

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


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)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)writetolabel:(int) 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 个值之后相互覆盖。

最佳答案

改变而不是

self.TextView.text = nil 

self.TextView.text=" "

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com