0

私はiOSとストーリーボードで学習/実験しています。セグエ中にテーブル ビュー コントローラーから詳細ビュー コントローラーにデータを渡す際に問題が発生します。

CSViewDetailViewController.h

@interface CSViewTopicDetailViewController : UIViewController {
    UILabel* topicTitleLabel;
    UITextView* topicDescriptionTextView;
}

@property (nonatomic, strong) UILabel *topicTitleLabel;
@property (nonatomic, strong) UITextView *topicDescriptionTextView;

@end

CSListTopicsViewController.m

 #pragma mark Table view selection
    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        if([[segue identifier] isEqualToString:@"CreateTopicSegue"]) {
            CSCreateTopicViewController *cvc = (CSCreateTopicViewController *)[segue destinationViewController];
            cvc.delegate = self;
        }
        else if ([[segue identifier] isEqualToString:@"ViewTopicDetailSegue"]) {
            NSLog(@"Preparing to segue to the View Topic view controller...");
            CSViewTopicDetailViewController *controller = (CSViewTopicDetailViewController *)[segue destinationViewController];
            NSIndexPath * indexPath = (NSIndexPath*) sender;

            controller.topicDescriptionTextView.text = topic.topicDescription;
            controller.topicTitleLabel.text = topic.topicTitle;
            controller.title = topic.topicTitle;
    NSLog(@"Set title label to: %@ from: %@", controller.topicTitleLabel.text, topic.topicTitle);
        NSLog(@"Set title label to: %@ from: %@", controller.topicTitleLabel.text, topic.topicTitle);

            NSLog(@"Segueing to the View Topic view controller...");
        }
    }

出力:

2012-05-01 13:51:01.301 ConversationStarters[42517:fb03] Preparing to segue to the View Topic view controller...
2012-05-01 13:51:01.302 ConversationStarters[42517:fb03] Set title label to: (null) from: Test topic 1
2012-05-01 13:51:01.303 ConversationStarters[42517:fb03] Segueing to the View Topic view controller...

セグエが呼び出され、UILabel を設定する行が実行され、Topic オブジェクトのデータが設定されている/null でないことがわかります。しかし、何らかの理由で、UILabel は渡されたテキスト値を格納していません。

何かご意見は?前もって感謝します。

4

0 に答える 0