0

私の現在の理解では、interface-builderを使用する代わりに、コード自体で座標を割り当てる必要があります。これを行うためのより良い方法はありますか?

現在、ログインビューを処理しようとしています。ポートレートモードではうまく機能しますが、ランドスケープモードではコンテンツの一部が非表示になります。これを処理する方法を提案してください。

ありがとう

GuruPrasadRGujjar。

4

1 に答える 1

0

これは 2 つの方法のいずれかで処理できます。1つ目はあなたが提案したもので、すべてのフレームを変更します.2つ目は、ランドスケープモードの別のビューを作成し、回転時に切り替えることです.

どちらの場合も、これら 2 つのメソッドを実装する必要があります

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}
-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
    if (toInterfaceOrientation==UIInterfaceOrientationPortrait || toInterfaceOrientation== UIInterfaceOrientationPortraitUpsideDown) {
        //put the portrait orientation here
        self.usernameField.frame=CGRectMake(xPortraitLocation, yPortraitLocation, xWidth, yWidth);
        ...

    }
    else{
        //do the same thing with everything but for landscape mode
    }

別のビューでは、self.view=self.lanscapeView または self.portraitView と言って、それらを切り替えるだけです。

最初の方法を使用する場合、インターフェイス ビルダーで偽のビューを作成して、すべてのアイテムを正しい場所に配置し、番号の割り当ての推測とチェックを排除する場所タブの下を確認できるようにすることがあります。

お役に立てれば。

于 2011-04-29T16:29:48.003 に答える