0

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

4

1 回答 1

3

将其包裹在一个 NSNumber 中:

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

// pass around ...

UIInterfaceOrientation orientation = (UIInterfaceOrientation)[[userinfo objectForKey:@"orientation"] integerValue];
于 2012-05-17T08:21:01.897 回答