簡體   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