如何从另一个类B (UIVIew)更新类a (UIViewController)的UI元素



我试图改变类A的背景颜色从类B,这是View-Controller和视图类型类,但我不能做到这一点。

我知道有一些我必须做线程。我试过使用performSelectorOnMainThread方法和更多的方法,但没有什么对我有效。

我的代码如下-

//  In Class B
-(void)method{
 ClassAViewController *AView=[[ClassAViewController alloc]init];
    AView.imageIndex=self.currentRenderingImageIndex;
    [AView findIndexOfImage];
}

现在我正在调用A类方法

-(void)findIndexOfImage
{
   NSLog(@"print the index is %i",imageIndex);// This is working fine
   AView.backgroundColor=[UIColor blueColor];// Here it is not updating my view.
}

我知道我问的这个问题很傻,请告诉我该怎么办

从类B调用这些行:

BaseViewController *objBaseViewController = [[BaseViewController alloc]initWithNibName:@"BaseViewController" bundle:[NSBundle mainBundle]];
    [objBaseViewController firstlink];

BaseViewController是我的类名你在这里给你的类名&firstlink是类A的方法你在这里给出你想调用的类A方法

最新更新