別のUITableViewControllerへのモーダルフリップ水平セグエアニメーションをトリガーするボタンを備えたUITableViewControllerがあります。「フリップサイド」には、押された場合にビューを閉じる単純な完了ボタンがあります。ビューを閉じるときに、FlipsideViewController の「テスト」文字列の値に応じて、MainTableViewController に「テスト」文字列を設定したいと考えています。しかし、その接続を機能させることはできません。以下に私のコードを投稿してください:
MainTableViewController.h
#import <UIKit/UIKit.h>
@interface MainTableViewController : UITableViewController
@property NSString *test;
@end
MainTableViewController.m
#import "MainTableViewController.h"
@interface MainTableViewController ()
@end
@implementation MainTableViewController
@synthesize test;
-(void)viewDidAppear:(BOOL)animated{
NSLog(@"%@", test);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{return 1;}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{return 10;}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"MainCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
return cell;
}
FlipsideTableViewController.h
#import <UIKit/UIKit.h>
#import "MainTableViewController.h"
@interface FlipsideTableViewController : UITableViewController
- (IBAction)done:(id)sender;
@end
FlipsideTableViewController.m
#import "FlipsideTableViewController.h"
@interface FlipsideTableViewController ()
@end
@implementation FlipsideTableViewController
- (IBAction)done:(id)sender{
NSString *test = @"Hello!";
// Push the test string to MainTableViewController
[self dismissViewControllerAnimated:YES completion:nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{return 1;}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{return 10;}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"FlipsideCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
return cell;
}
@end