English 中文(简体)
正确将我的按钮与我的观点链接( UININAGGATION 主计长)?
原标题:Correctly link my buttons to my views (in UINavigationController)?

如果这个问题听起来有点新奇, 我很抱歉, 但我是一个初学者, 想要改进。 因此, 我有一个导航控制器嵌入了整个应用程序。 我的主视图有一个按钮, 连接到另一个视图 。

以下是我在主要观点中所做的:

小时.h

@property (nonatomic, retain) IBOutlet UIButton *button;

..........

在 IB 中, 我在我的主视图中添加了一个按钮, 并增加了另一个 View Consultaner 的按钮, 我改变了该类。 还有以下链接 :

  • button -> Button
  • button -> OtherViewController (Push)

现在,我的问题是,我错过了什么可以添加到我的代码或 IB?我还需要 IB Action 吗?

非常感谢你的建议...

最佳回答
-(IBAction)clickButton:(id)sender{

if (!createViewController) {
                createViewController = [[CreateViewController alloc] initWithNibName:@"CreateViewController" bundle:nil];

            }

            UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
            self.navigationItem.backBarButtonItem = backBarButtonItem;
            [backBarButtonItem release];
            [self.navigationController pushViewController:createViewController animated:YES];
}
问题回答

是的, 您需要一种方法来定义您按钮的动作 。

.h:

- (IBAction)buttonPressed:(id)sender;

.时:

- (IBAction)buttonPressed:(id)sender { // what you want to do when the button is pressed }

然后从您的界面点击按钮, 从连接检查员点击, 控制按钮单击“ 触摸内部” 的收音机按钮, 连接到文件所有者, 并选择方法 - 按键 。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签