更改 ios 相机叠加层 UIPickercontroller 中的标签文本

Change text of label in ios camera overlay UIPickercontroller

我正在尝试以不同的方法通过计时器更改我在 UIImagePickerviewController 上的 UIView 覆盖层中以编程方式创建的标签文本,但是当然当我尝试以这种方式更改文本时

labelname.text = @"TEST";

我收到错误 "use of undeclared identifier labelname"

如何引用该特定标签?每次计时器滴答时我都应该创建一个新标签吗?

我试图在 .h 文件中声明它,但我猜我只是在创建一个不同的标签...有什么想法吗?

只需将标签作为一个整体传递给定时器函数:

假设您的标签在 ViewDidLoad 中定义如下:

- (void)viewDidLoad 
{
     //Do Something here
     UILabel  * label = [[UILabel alloc] 
     initWithFrame:CGRectMake(xcoordinateLabel, ycoordinateLabel, width, height)];
     label.backgroundColor = [UIColor clearColor];
     label.textAlignment = UITextAlignmentCenter;
     label.textColor=[UIColor whiteColor];
     label.text = @"TEST";
     [self.view addSubview:label];
     [self changeLabelText:label];
 }

你的 changeLabelText 被定义为这个有一些延迟:

- (void) changeLabelText:(UILabel *)label
{
    //Changing Values after 10s Delay
    double delayInSeconds = 10.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 
    (int64_t)(delayInSeconds * NSEC_PER_SEC));

    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    label.text = @"TESTING Change";
    });
}

您的定时器功能可以替代 changeLabelText