有一个视图控制器,带有导航条,完成按钮,两个文本域。按下完成按钮时,会调用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文件设置的,是空的。