質問

uitableviewcellをサブクラス化し、layoutsubviewsメソッドを介していくつかのサブビューを組み込みました。すべてのビューは、inittylewithedメソッドで割り当てられ、開始され、フレームは次のようにleautsupviewsメソッドで設定されます。

initWithStyle:... {
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectZero];
myLabel.someProperties = Configured;
[self.contentView addSubview:myLabel];

layoutSubviews {
CGRect labelRect = CGRectMake(10.0f, 5.0f, 35.0f, 180.0f);
myLabel.frame = labelRect;

viewcontrollerでshouldautorotateorientationをyesに設定すると、NavigationController、TableView、およびUitoolbarが適切に回転しますが、TableViewcellsの内容は動きません。私は、自動化するマスコンに関してどこに、何を追加するかについては明確ではありません。私がこれまでに試した組み合わせは何もしていません。誰かが私に手を差し伸べられますか?

ありがとう!

役に立ちましたか?

解決

私が思いついた答えは、条件付きコーディングを使用して、レイアウトサブビューのメソッドで、方向に応じてビューフレームを配置することです

-(void)layoutSubviews {
    //For portrait mode (NOT PORTRAIT UPSIDE DOWN)
    if ( UIDeviceOrientationIsPortrait([[UIDevice currentDevice]orientation]) ) {
        CGRect portraitFrame = CGRectMake(Portrait Frame Coordinates);
        myLabel.frame = portraitFrame;
    } else {
    //For landscape modes
        CGRect landscapeFrame = CGRectMake(landscape frame coordinates);
        myLabel.frame = landscapeFrame;
    }
}

一緒にハッキングされているように見えますが、サブクラス化されたuitableviewcellsで動作します

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top