[英]Adding UI Bar Button Items for WebView but app crashing
I've added the following code to my iOS project in XCode. 我已经在XCode的iOS项目中添加了以下代码。 It allows me to add multiple buttons to my UINavigation Controller - the items show fine in the app but when I press the 'Refresh' or 'Back' button the app crashes
它允许我向UINavigation Controller中添加多个按钮-该项目在应用程序中显示正常,但是当我按“刷新”或“返回”按钮时,应用程序崩溃
What I'm trying to do is create 3 buttons - Refresh, GoBack and GoForward. 我想做的是创建3个按钮-刷新,GoBack和GoForward。
The error Im getting says Undeclared selector 'refresh' 我收到的错误提示未声明的选择器“刷新”
// 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];
Check the declaration/definition of your refresh
method. 检查
refresh
方法的声明/定义。
As per your code action:@selector(refresh:);
根据您的代码
action:@selector(refresh:);
the refresh
method should have atleast one argument. refresh
方法应至少包含一个参数。
If your definition of refresh
method has not arguments then it should be like action:@selector(refresh);
如果您的
refresh
方法定义没有参数,则应类似于action:@selector(refresh);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.