0

I developed an IOS Framework (objective C) and want to integrate it in Kony project. The Framework function to be called will display a UIView.

This function was used in Kony project to load the UI :

- (void)viewDidLoad {
    [super viewDidLoad];
    GlobalVariables = [GlobalVars sharedInstance];
    CameraBioselfie *cam;
    cam =[[CameraBioselfie alloc] init];
    [self presentViewController:cam animated:YES completion:nil];
    [self.view addSubview:[cam window]];

    dispatch_group_t group = dispatch_group_create(); dispatch_group_async(group,dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^ {
        while (GlobalVariables.response.length==0 && GlobalVariables.error.length==0){

        }
        if(GlobalVariables.response.length==0){
            self.result =GlobalVariables.error;
        }
        else if([GlobalVariables.response containsString:GlobalVariables.username]){
            self.result = @"Recognized";
        }
        else{
            self.result = GlobalVariables.response;
        }

        NSArray *status = @[self.result];
        [self.callbackfunction executeWithArguments:status];

        dispatch_sync(dispatch_get_main_queue(), ^{
            [self dismissViewControllerAnimated:YES completion:nil];
        });
    });
}

When it gets to this line:

[self.view addSubview:[cam window]];

I receive the following error:

This application is modifying the auto layout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.

Please note that if the framework is integrated in an Xcode objective c project and called the same way, i don't have this issue

  • I think the issue may be with [self presentViewController:cam animated:YES completion:nil]; [self.view addSubview:[cam window]]; these lines. In 1st line you are presenting cam and again you are adding it in next line. Can you check it again – user4261201 Nov 28 '17 at 13:35
  • actually it worked when i used it like this : dispatch_async(dispatch_get_main_queue(), ^{ [self presentViewController:cam animated:YES completion:nil]; }); [self.view addSubview:[cam window]]; – Lama Khoury Nov 30 '17 at 10:12

1 Answers1

0

Once try by adding subview on main thread like,

  dispatch_async(dispatch_get_main_queue(), ^{


   [self.view addSubview:[cam window]];

 });
Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75