我是使用 xcode 开发的新手,我正在关注苹果的教程:“第二个 ios 应用程序教程”。我在我的场景“添加瞄准视图控制器”中添加了一个按钮,我想将此视图切换到另一个(BirdsViewController),它有一个鸟的名字列表。在我的故事板中,我在按钮和 BirdsViewController 之间创建了一个 segue,并且还连接了按钮以在内部进行修饰,但是当我运行应用程序时,按钮没有出现。有人可以帮助我吗?谢谢。这是我的代码(我没有实现任何其他方法):
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;
添加SightingViewController.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];
}