这是我在 SO 上的第一篇文章,所以你好!
我也是 Xcode 和 Obj-C 的新手,所以不要太苛刻。
我正在关注斯坦福大学 youtube.com/watch?v=L-FK1TrpUng 的演示,由于某种原因,我遇到了错误。与其从头开始,我更愿意找出我哪里出错了。
好的,就这样吧。
我有两个视图控制器,我目前正在学习推送和弹出。
我的第一个视图控制器 (firstViewController.h) 标头:
#import <UIKit/UIKit.h>
@interface FirstViewController : UIViewController {
}
- (IBAction)pushViewController:(id)sender;
@end
然后最初这是在实现文件(firstViewController.m)中设置的,像这样
#import "firstViewController.h"
@implementation FirstViewController
- (IBAction)pushViewController:(id)sender{
}
此时使用 IB 我 ctrl 从“文件所有者”拖到“UIButton”并连接“pushViewController”
但是,在途中的某个地方,我收到了某种错误,我忽略了它。
现在我将第二个视图控制器添加到我的 firstViewController.m 中,如下所示;
#import "firstViewController.h"
#import "secondViewController.h"
@implementation FirstViewController
- (IBAction)pushViewController:(id)sender{
SecondViewController *secondViewController = [[SecondViewController alloc] init];
secondViewController.title = @"Second";
[self.navigationController pushViewController:secondViewController animated:YES];
[secondViewController release];
}
我之前收到的错误似乎以某种方式阻止了我从我的 secondViewController 笔尖中的 textLabel 拖动 ctrl
(secondeViewController.h)
#import "firstViewController.h"
#import "secondViewController.h"
@implementation FirstViewController
- (IBAction)pushViewController:(id)sender{
SecondViewController *secondViewController = [[SecondViewController alloc] init];
secondViewController.title = @"Second";
[self.navigationController pushViewController:secondViewController animated:YES];
[secondViewController release];
}
所以我通过在 firstViewController.xib 中右键单击它从我的原始 UIButton 中删除了引用。
现在我无法重新创建从“文件所有者”到“UIButtons”、“pushViewController”插座的链接(它是一个插座还是一个动作?),也不能在我的 secondViewControllers 笔尖中创建从“文件所有者”到“UILabel”的链接'。
有什么帮助吗?
如果有人感兴趣,这里的项目文件。http://zer-o-one.com/upload/files/PushPop.zip
非常感激。