为WebView添加UI栏按钮项但应用程序崩溃

时间:2013-12-27 12:39:23

标签: c++ ios iphone objective-c xcode

我已将以下代码添加到XCode中的iOS项目中。它允许我向我的UINavigation控制器添加多个按钮 - 项目在应用程序中显示正常但是当我按下“刷新”或“返回”按钮时应用程序崩溃

我要做的是创建3个按钮 - Refresh,GoBack和GoForward。

我得到的错误显示未申报选择器'刷新'

// Create the refresh, fixed-space (optional), and profile buttons.
UIBarButtonItem *refreshBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh:)];




//    // Optional: if you want to add space between the refresh & profile buttons
//    UIBarButtonItem *fixedSpaceBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
//    fixedSpaceBarButtonItem.width = 12;

UIBarButtonItem *profileBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(goToProfile)];
profileBarButtonItem.style = UIBarButtonItemStyleBordered;

self.navigationItem.rightBarButtonItems = @[profileBarButtonItem, /* fixedSpaceBarButtonItem, */ refreshBarButtonItem];

2 个答案:

答案 0 :(得分:0)

请关注Link

将在导航栏中添加更多按钮

答案 1 :(得分:0)

检查refresh方法的声明/定义。

根据您的代码action:@selector(refresh:);refresh方法至少应包含一个参数。

如果您对refresh方法的定义没有参数,那么它应该像action:@selector(refresh);