繁体   English   中英

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

[英]Adding UI Bar Button Items for WebView but app crashing

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

我想做的是创建3个按钮-刷新,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];

请点击链接

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

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

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

如果您的refresh方法定义没有参数,则应类似于action:@selector(refresh);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM