我使用 swift 3 和 Xcode 8.3.2 制作 iOS应用,并且它正常工作(适合所有iPhone屏幕大小)但在 iPad 中有适合的问题
我在常规/目标设置中设置 iPhone 模式
我已经完成了这个过程,没有问题
请帮我修理它。我不想设置环球
看到这个:
答案 0 :(得分:0)
您可以从info.plist
为iPad和iPhone设置不同的故事板,也可以从appdelegate加载特定的故事板。你可以查看this link out
答案 1 :(得分:0)
那么您可以通过在班级中使用以下代码来更改屏幕尺寸或组件约束值,从而可以为iphone和ipad设置视图。
@ControllerAdvice
public class PutMyEntityBodyAdvice implements ResponseBodyAdvice<Object> {
@Override
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
// Write the condition to check if beforyBodyWrite should be called
return returnType.getParameterType().equals(ResponseEntity.class);
}
@Override
public Object beforeBodyWrite(Object object, MethodParameter returnType, MediaType selectedContentType,
Class<? extends HttpMessageConverter<?>> selectedConverterType,
ServerHttpRequest request, ServerHttpResponse response) {
// Check if it is a PUT request for MyEntity object
if (HttpMethod.PUT.equals(request.getMethod()) && object instanceof PersistentEntityResource) {
PersistentEntityResource persistentEntityResource = (PersistentEntityResource) object;
if (persistentEntityResource.getContent().getClass().equals(MyEntity.class)) {
// Add custom header or manipulate response object
response.getHeaders().add("X-Save", "MyEntity");
}
}
return object;
}
}
现在您可以像这样设置约束:==
struct Device {
// iDevice detection code
static let IS_IPAD = UIDevice.current.userInterfaceIdiom == .pad
static let IS_IPHONE = UIDevice.current.userInterfaceIdiom == .phone
static let IS_RETINA = UIScreen.main.scale >= 2.0
static let SCREEN_WIDTH = Int(UIScreen.main.bounds.size.width)
static let SCREEN_HEIGHT = Int(UIScreen.main.bounds.size.height)
static let SCREEN_MAX_LENGTH = Int( max(SCREEN_WIDTH, SCREEN_HEIGHT) )
static let SCREEN_MIN_LENGTH = Int( min(SCREEN_WIDTH, SCREEN_HEIGHT) )
static let IS_IPHONE_4_OR_LESS = IS_IPHONE && SCREEN_MAX_LENGTH < 568
static let IS_IPHONE_5 = IS_IPHONE && SCREEN_MAX_LENGTH == 568
static let IS_IPHONE_6 = IS_IPHONE && SCREEN_MAX_LENGTH == 667
static let IS_IPHONE_6P = IS_IPHONE && SCREEN_MAX_LENGTH == 736
static let IS_IPHONE_X = IS_IPHONE && SCREEN_MAX_LENGTH == 812
}