Adding tile to MS Band warning (iOS)

你离开我真会死。 提交于 2019-12-13 19:02:57

问题


I am trying to add a tile with code from the MSBand documentation.

EDIT: I never get the log output from these 2lines:
NSLog(@"adding tile...");
if(error)NSLog(@"error adding tile to band: %@", error);
, which i find very odd

 NSError *error;
MSBIcon *smallIcon = [MSBIcon iconWithUIImage:[UIImage imageNamed:@"MSB_white_x"] error:&error];
if(error)NSLog(@"small icon error: %@", error);

MSBIcon *tilecon = [MSBIcon iconWithUIImage:[UIImage imageNamed:@"MSB_white_xx"] error:&error];
if(error)NSLog(@"big icon error: %@", error);

NSUUID *tileID = [NSUUID UUID];
MSBTile *tile = [MSBTile tileWithId:tileID name:@"Something" tileIcon:tilecon smallIcon:smallIcon error:&error];
if(error)NSLog(@"tile creation error: %@", error);
[self.sensor.client.tileManager addTile:tile completionHandler:^(NSError *error) {
    NSLog(@"adding tile...");
    if(error)NSLog(@"error adding tile to band: %@", error);
}];

But when I try to run the app I get the following warning:

Warning: Attempt to present MSBAddTileDialogViewController_iOS: 0x14f534e20 on PersonalStatisticsViewController: 0x14f5116b0 whose view is not in the window hierarchy!

I noticed that the "on view controller" is always the root view controller regardless. Hence when I first got the warning from within another view controller than root I tried changing the root to whatever VC i was currently in. I run the code from -()viewDidAppear I really don't understand why I get this warning, mainly because I see no reason for the tile-creation to try and add anything to the app VCs (it should just add the tile to the MSBAND).

Does anybody have any idea whats going on? Thanks in advance.


回答1:


Where are you making the addTile call from?

If you are calling from in the viewDidLoad then you will see this problem. You should move your addTile call into viewDidAppear.

Reference this StackOverflow question: whose view is not in the window hierarchy



来源:https://stackoverflow.com/questions/29660137/adding-tile-to-ms-band-warning-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!