iOS:如何通过NSNotification发送UIInterfaceOrientation对象

时间:2012-05-17 08:11:52

标签: ios uiinterfaceorientation nsnotifications

我想在NSNotification的userinfo字典中传递UIInterfaceOrientation对象。我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:3)

将其包裹在NSNumber中:

id orientationObject = [NSNumber numberWithInteger:UIInterfaceOrientationPortrait];
[userinfo setObject:orientationObject forKey:@"orientation"];

// pass around ...

UIInterfaceOrientation orientation = (UIInterfaceOrientation)[[userinfo objectForKey:@"orientation"] integerValue];