336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

앱을 만들때 세로모드만 사용하여 가로모드를 막아야 할 경우 필요한 코드 입니다.

가르모드가 필요없는 뷰컨트롤러에 넣어 주면 적용됩니다.


(Objective-C 코드)

1
2
3
4
- (NSUInteger) supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait; //세로 화면만 허용
}
cs

UIInterfaceOrientation 속성입니다.

UIInterfaceOrientationMaskPortrait //세로 화면만 허용

UIInterfaceOrientationMaskAll //전체 화면 허용

UIInterfaceOrientationMaskPortraitUpsideDown //거꾸로만 허용

UIInterfaceOrientationMaskLandscape; //가로화면만 허용


(Swift 코드)

1
2
3
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.Portrait
}
cs

UIInterfaceOrientation 속성입니다.

UIInterfaceOrientationMask.Portrait //세로 화면만 허용

UIInterfaceOrientationMask.All //전체 화면 허용

UIInterfaceOrientationMask.PortraitUpsideDown //거꾸로만 허용

UIInterfaceOrientationMask.Landscape //가로화면만 허용

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

위젯을 만들때 왼쪽 여백 조금 남습니다.

디자인상 왼쪽 여백 필요 하시면 그냥 쓰시면 되지만 또 디자인상 불필요할때도 있습니다.

그 왼쪽 여백을 없애주는 코드 입니다. 그냥 추가만 해주시면 되요!


(Objective-C 코드)

1
2
3
-(UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMarginInsets {
    return UIEdgeInsetsZero
}


cs

(Swift 코드)

1
2
3
func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets {
    return UIEdgeInsetsZero
}
cs


336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

최상단에 있는 rootViewController를 가지고 오는 코드입니다.

(Objective-C 코드)

1
UIViewController * viewController = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
cs

(Swift 코드)

1
let viewController: UIViewController = UIApplication.sharedApplication().delegate!.window!!.rootViewController!
cs


+ Recent posts