私はxcodeを使った開発に不慣れで、アップルのチュートリアル「Second'siosapptutorial」に従っています。シーンに「SightingViewControllerの追加」ボタンを追加しましたが、このビューを鳥の名前のリストがある別のビュー(BirdsViewController)に切り替えたいと思います。ストーリーボードでは、ボタンとBirdsViewControllerの間にセグエを作成し、ボタンを接続して内部を修正しましたが、アプリを実行してもボタンが表示されません。誰か助けてもらえますか?ありがとうございます。これが私のコードです(私は他のメソッドを実装していません):
AddSightingViewController.h
@class BirdSighting;
@interface AddSightingViewController : UITableViewController
@property (weak, nonatomic) IBOutlet UITextField *birdNameInput;
@property (weak, nonatomic) IBOutlet UITextField *locationInput;
@property (strong, nonatomic) BirdSighting *birdSighting;
@property (strong, nonatomic) UIButton *showBirds;
-(IBAction)displayBirds:(id)sender;
AddSightingViewController.m
#import "AddSightingViewController.h"
#import "BirdSighting.h"
#import "BirdsViewController.h"
#import <UIKit/UIKit.h>
@class BirdSighting;
@interface AddSightingViewController ()
@end
@implementation AddSightingViewController
@synthesize showBirds;
-(BOOL)textFieldShouldReturn:(UITextField *)textField {
if((textField == self.birdNameInput) || (textField == self.locationInput)) {
[textField resignFirstResponder];
}
return YES;
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([[segue identifier] isEqualToString:@"ReurnInput"]) {
if ([self.birdNameInput.text length] || [self.locationInput.text length])
{
BirdSighting *sighting;
NSDate *today = [NSDate date];
sighting = [[BirdSighting alloc] initWithName:self.birdNameInput.text
location:self.locationInput.text date:today];
self.birdSighting = sighting;
}
}
}
BirdsViewController *viewController;
-(IBAction)showBirds:(id)sender {
viewController =
[[BirdsViewController alloc]
initWithNibName:@"BirdsViewController" bundle:nil];
[[self navigationController] pushViewController:viewController animated:YES];
}