gpt4 book ai didi

ios - self.view setNeedsDisplay 和 self.view setNeedsLayout 不起作用

转载 作者:行者123 更新时间:2023-12-03 07:05:38 25 4
gpt4 key购买 nike

我有一个主视图 Controller 显示在屏幕上,一个类(代表)在后台运行获取位置。当我得到结果时,我调用 View Controller 中的委托(delegate)方法来更新屏幕上的标签。我尝试了多种方法,但屏幕仍然没有更新。

方法如下:

-(void) updateDisplay
{

NSLog(@"%@",myPosition.currentArea);
_area.text = [NSString stringWithFormat:@"area = %@",myPosition.currentShopArea];


//[self.view performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:YES];
[self.view setNeedsDisplay];
//[self.view setNeedsLayout];
}

我检查控制台,它显示了正确的区域,但屏幕上仍然显示空。我尝试了所有三种方法(上面已注释),但这些方法都没有更新屏幕。

最佳答案

你可以尝试两件事:

  1. 在主线程上调用updateDisplay:

    [delegate performSelectorOnMainThread:@selector(updateDisplay) withObject:nil waitUntilDone:YES];

    最后,它正在访问 UIKit,所以最好做得正确;

  2. 如果这没有帮助,请尝试:

    [_area setNeedsDisplay];

    在这种情况下,建议在主线程上调用该方法。

关于ios - self.view setNeedsDisplay 和 self.view setNeedsLayout 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15358602/

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