[英]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.