完了ボタンのあるナビゲーション バーと 2 つのテキスト フィールドを持つビュー コントローラーがあります。完了ボタンが押されると、メソッドpostInfo
が呼び出されます。実装は次のとおりです。
- (void)postInfo{
ListingViewController* lvc = [[ListingViewController alloc] init];
NSString* listingName = listingNameField.text;
NSString* listingPrice = listingPriceField.text;
NSLog(@"%@", listingName);
NSLog(@"%@", listingPrice);
[lvc.titleLabel setText:listingName];
[lvc.priceLabel setText:listingPrice];
[self.navigationController pushViewController:lvc animated:YES];
}
ここにListingViewController.h
:
#import <UIKit/UIKit.h>
@interface ListingViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@end
UILabel は xib ファイルを介して設定され、空です。リクエストに応じて、他のコードが必要な場合は投稿します。