菜鸟教程小白 发表于 2022-12-11 19:58:43

ios - UILabel 在前一个值之上覆盖


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

<pre><code>//AppDelegate.mm

@implementation AppDelegate

ViewController *vc;

- (void)feedSamplesToEngine:(UInt32)audioDataBytesCapacity audioData:(void *)audioData {
    if(check&gt;0 || check==-1)
    {
      ;
    }
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    vc = (ViewController *)self.window.rootViewController;
}
</code></pre>

<p>..</p>

<pre><code>//ViewcONTROLLER.m

@interface ViewController ()
{ AVAudioSession *session;
}

@end

@implementation ViewController

@synthesize appDelegate; //global declaration bitches

- (void)viewDidLoad {
    ;

   appDelegate = (AudioRecorderAppDelegate *)[ delegate];

    self.TextView.text=@&#34;OTP&#34;;
    ;

}

- (void)writetolabel:(int) check{
    self.TextView.text=nil;

    if(check==-1)
      self.TextView.text= ;
    else
      self.TextView.text= ;

}


- (void)dealloc {
    ;
    ;
}
@end
</code></pre>

<p>我尝试搜索相同的内容,但没有一个答案能解决我的问题。
这些值定期更改,问题不在于传递的值,而是在前 3-4 个值之后它们相互覆盖。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>改变而不是</p>

<pre><code>self.TextView.text = nil
</code></pre>

<p>到</p>

<pre><code>self.TextView.text=&#34; &#34;
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - UILabel 在前一个值之上覆盖,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/44778881/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/44778881/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - UILabel 在前一个值之上覆盖