gef*_*rce 2 iphone objective-c uiviewcontroller ios
我想知道为什么在iOS模拟器上测试时通过跟踪我的UIViewController中的代码没有控制台输出 - 它只能通过在设备上进行测试来跟踪.
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
NSLog(@"willRotateToInterfaceOrientation: ", toInterfaceOrientation);
}
Run Code Online (Sandbox Code Playgroud)
我如何打印出UIInterfaceOrientation值(枚举类型)?很高兴得到你的帮助......谢谢
Jac*_*kin 10
你的格式说明符在哪里?
UIInterfaceOrientation是一个typedef enum,而不是一个对象,所以你不能%@用作格式说明符.
应该是这样的:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
NSLog(@"willRotateToInterfaceOrientation: %d", toInterfaceOrientation);
}
Run Code Online (Sandbox Code Playgroud)
如果你真的需要这种"漂亮的打印"功能,你可以通过它运行它switch,如下所示:
NSString *orient;
switch(toInterfaceOrientation) {
case UIInterfaceOrientationLandscapeRight:
orient = @"UIInterfaceOrientationLandscapeRight";
break;
case UIInterfaceOrientationLandscapeLeft:
orient = @"UIInterfaceOrientationLandscapeLeft";
break;
case UIInterfaceOrientationPortrait:
orient = @"UIInterfaceOrientationPortrait";
break;
case UIInterfaceOrientationPortraitUpsideDown:
orient = @"UIInterfaceOrientationPortraitUpsideDown";
break;
default:
orient = @"Invalid orientation";
}
NSLog(@"willRotateToInterfaceOrientation: %@", orient);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1973 次 |
| 最近记录: |