【发布时间】:2013-01-28 18:16:51
【问题描述】:
我是使用 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;
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];
}
【问题讨论】:
标签: ios