1
[message setBackgroundColor:[UIColor redColor]];
[message setFrame:CGRectMake(message.frame.origin.x, message.frame.origin.y, message.frame.size.width, 20)];

背景色が変わるので IB の接続は問題ありませんが、UITextView のサイズは変わりません。複数の方法を試しましたが、位置やサイズを変更できません。

ボタンからアクションを実行すると機能しますが、didFinishPickingMediaWithInfo からのコールバックでは機能しません。

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

    [picker dismissViewControllerAnimated:NO completion:^{

        [UIView animateWithDuration:0.1
                          delay:0.0
                        options: UIViewAnimationCurveEaseOut // Doesnt really matter since its so fast
                     animations:^{
                         [message setFrame:CGRectMake(message.frame.origin.x, message.frame.origin.y, message.frame.size.width, 20)];
                     } 
                     completion:^(BOOL finished){[message setBackgroundColor:[UIColor redColor]]; }];
4

3 に答える 3

1

これを試して:

[message setBackgroundColor:[UIColor redColor]];

[UIView animateWithDuration:0.1
delay:0.0
options: UIViewAnimationCurveEaseOut // Doesnt really matter since its so fast
animations:^{
    [message setFrame:CGRectMake(message.frame.origin.x, message.frame.origin.y, message.frame.size.width, 20)];
} 
completion:^(BOOL finished){ }];
于 2012-06-18T21:59:22.533 に答える
0

最近、UITextView のコンテンツ サイズを取得するには (したがって、そのフレームをそのコンテンツに「フィット」するように設定し、スクロールは必要ありません)、最初にテキスト ビューをサブビューとして追加する必要があることがわかりました。子ビューになるまで、contentSize は正しい値を返しません (フレームの設定も同様に機能しないのでしょうか?)。

推測ですが...

于 2012-06-18T22:54:19.283 に答える
0

このコードをどのメソッドから呼び出していますか? フレーム設定がその後の変更によって上書きされる可能性があります。フレーム サイズはまだ設定されていませんが、呼び出されるviewDidLoadまでに設定する必要がviewWillAppearあります。そこで追加のレイアウトを実行してください。

于 2012-06-18T20:59:06.653 に答える