问题
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