0

我用UINavigationbar,效果很好。

但是现在我有一个全局参数来计算在索引处使用的参数(我想回来的屏幕索引)pushUIViewControllerpopToUIViewController它有效,但是当我单击UINavigation左按钮返回上一个屏幕时出现错误,这使得参数继续计数(++)。

然后当我回到屏幕上时,我希望参数有不同的值。

如何检查按钮是否UINavigationbar被点击???

提前致谢

4

2 回答 2

1
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(method:)];
cancelEdit:, the selector, is in the current class (self) and is defined as:

- (void) method: (id) sender
{
//use nslog to print string (or)perform any action to change view background colors;
nslog("click"):
(or)
self.view.backgroundcolor=[UIColor redcolor];
}
于 2012-10-08T04:27:21.120 回答
1

在导航栏上手动添加按钮:

 UIButton *titleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[titleButton setTitle:@"myTitle" forState:UIControlStateNormal];
titleButton.frame = CGRectMake(0, 0, 70, 44);
titleButton.font = [UIFont boldSystemFontOfSize:16];
[titleButton addTarget:self action:@selector(titleTap:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.titleView = titleButton;

添加 titleTap 方法来捕捉点击事件:

    - (IBAction) titleTap:(id) sender
{
    NSLog(@"Title tap");
}
于 2012-10-08T03:39:25.620 回答