1

UITableView オブジェクトを使用するマスター ビューと、ユーザー選択をプッシュした後に表示される詳細 ViewContrailer に情報があります。

私の課題は、詳細ビューのスクロール領域の上部に戻らない UITextView オブジェクトでのスクロールです。

ユーザーはマスター ビュー コントローラーのリストから詳細オブジェクトを選択し、それを詳細ビュー コントローラーに表示します。次に、そのビューの UITextView オブジェクト (dogScrollingInfoTextView) 内をスクロールし、上の行が表示されないようにさらに下に移動します。その後、Master View Controller に戻り、別の行を選択します。詳細ビューに戻ると、新しいオブジェクトの UITextView オブジェクト (dogScrollingInfoTextView) は、前のビューが残した場所にまだ配置されています。

detailViewController でこの UITextView に渡されるオブジェクトは、Master View Controller では次のようになります。

  self.detailViewController.dogScrollingInfo = dog.whatMakesDogSpecial;

元のクラス定義では、このプロパティは次のように宣言されています

@property (強力、非アトミック) NSString *whatMakesDogSpecial;

detailView コントローラ クラス内でビューに転送するために使用されるオブジェクトは、次のように宣言されます。

 @property (strong, nonatomic) NSString *dogScrollingInfo;
 @property (weak, nonatomic) IBOutlet UITextView *dogScrollingInfoTextView;

そして、detailViewController 実装では、転送は次のようになります

 self.dogScrollingInfoTextView.text = [self.dogScrollingInfo description];

スクリーン ショットを添付する必要があるかどうかわかりません。他のコードを入れる必要がありますか?(各View Controllerクラスから1つずつ、以下に2つのメソッドを配置しました)

UITextView クラスまたは UIView クラスでのスクロールに特に関連するものは何も見つかりません。これは、プログラムで何かを行う必要があることを示しています。これは、InterfaceBuilder と関係があるようです。私はxibのNOTストーリーボードを使用しています。しかし、この動作を変更するさまざまなインスペクターの選択肢が見つかりません。

詳細View Controllerクラスで使用するconfigureViewは、おそらくこれに使用する適切な方法ではないでしょうか? Single View プロジェクト テンプレートからアプリケーションを構築しましたが、Xcode Master-Detail プロジェクト テンプレートで configureView メソッドを使用する例を見つけたと思います。そうでない場合、どの方法を使用するかをどのように判断しますか?

このような課題を解決するためにアップルのドキュメントを使用する方法を学ぼうとしていますが、それをナビゲートするのは難しいと思います. そのため、ドキュメントをより適切に使用する方法についての指針は大歓迎です。

.... Master View Controller クラスからのコード スニップ...

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    if (!self.detailViewController) {
        self.detailViewController = [[HardlyWorkingDogsDetailViewController alloc]
                                     initWithNibName:@"HardlyWorkingDogsDetailViewController"
                                     bundle:nil ];

    }
    NSLog(@"The user selected dog @array position %d", indexPath.row);

    Dog *dog = self.sortedDogDictionaryArray[indexPath.row];


    self.detailViewController.dogName= dog.dogName;

    self.detailViewController.dogLicense = dog.licenseString;

    self.detailViewController.dogScrollingInfo = dog.whatMakesDogSpecial;

    self.detailViewController.dogPhoto = dog.dogPhoto;


    [self.navigationController pushViewController:self.detailViewController animated:YES];


  }

.... Detail View Controller クラスからのコード スニップ...

-(void)configureView {
    //NSLog(@"ConfigureView # 1 in detail vu");
    if (self.dogLicense) {

        self.dogLicenseUILabel.text = [self.dogLicense description];
        self.dogNameUIText.text = [self.dogName description];


        self.dogScrollingInfoTextView.text = [self.dogScrollingInfo description];

        self.dogPhotoUIImage.image = self.dogPhoto;


    }
}

ローレルありがとう

4

1 に答える 1