我一直在网上寻找解决方案,但一无所获.我正在尝试使我的iOS 5应用iOS 6兼容.我无法让定位的东西正常工作.我无法检测到旋转何时发生.这是我正在尝试的代码:
- (BOOL)shouldAutorotate {
return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
// pre-iOS 6 support
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
Run Code Online (Sandbox Code Playgroud)
新的supportedInterfaceOrientation:方法被调用就好了.但是,shouldAutorotate方法不会触发.我需要在旋转时进行一些图像交换,但我无法得到旋转即将发生的任何迹象.
提前致谢.
我的课:
class ExampleBean {
private String _firstField;
private String _secondField;
// respective getters and setters
}
Run Code Online (Sandbox Code Playgroud)
我希望看起来如下:
{
"FirstField":"value",
"SecondField":"value"
}
Run Code Online (Sandbox Code Playgroud)
而不是这样
{
"_FirstField":"value",
"_SecondField":"value"
}
Run Code Online (Sandbox Code Playgroud)
我按如下方式初始化解析器:
GsonBuilder builder = new GsonBuilder();
builder.setDateFormat(DateFormat.LONG);
builder.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE);
builder.setPrettyPrinting();
set_defaultParser(builder.create());
Run Code Online (Sandbox Code Playgroud)
我可以看到API和"FieldNamePolicy" 的文档,但我很惊讶,不提供跳过"_"的选项我也知道我可以使用注释...
@ SerializedName (" custom_naming ")
Run Code Online (Sandbox Code Playgroud)
...但是我不想为alllllll我的领域写这个......
对我来说区分局部变量和类的字段非常有用.:( 任何的想法?
编辑:会有很多明显的解决方案,(继承,gson覆盖方法,常规表达).我的问题更侧重于是否存在gson的原生解决方案或更少侵入性的修复?
也许我们可以建议新的FieldNamePolicy?