問題: 內置editButtonItem創建一個新的UITableViewController類時,當我刪除註釋斜槓(//
)不工作是Xcode的自動註釋掉。通過不起作用,我的意思是編輯按鈕並沒有出現。刷單元也不起作用。editButtonItem沒有顯示出來
嘗試解決方案: 我試圖按照已發佈在其他stackoverflow線程上的各種解決方法無濟於事。我發現的大多數帖子都談論編輯按鈕的各個方面無法正常工作(例如,沒有顯示出來的減號等),但我發現很少有編輯按鈕根本不顯示的帖子。
Hunch: 我有一種預感,它可能與UITableViewController沒有正確實現有關。我對面向對象編程和Objective-C都很陌生,所以我很抱歉如果答案是非常基本的 - 但是,嘿,它是學習過程的一部分。任何幫助深表感謝。
代碼:
_ __ _ .H
#import <UIKit/UIKit.h>
#import "IndividualRecipeViewController.h"
@class BrowsePrivateRecipeViewController;
@protocol BrowsePrivateRecipeViewControllerDelegate
- (void)browsePrivateRecipeViewControllerDidFinish:(BrowsePrivateRecipeViewController *)controller;
@end
@interface BrowsePrivateRecipeViewController : UITableViewController
@property (weak, nonatomic) id <BrowsePrivateRecipeViewControllerDelegate> delegate;
@property (assign, nonatomic) NSUInteger listLength;
@property (strong, nonatomic) NSDictionary *dictionaryOfRecipes;
@property (strong, nonatomic) NSMutableArray *arrayOfRecipeNames;
// ... methods
@end
_ __ _ .M
@interface BrowsePrivateRecipeViewController()
@end
@implementation BrowsePrivateRecipeViewController
@synthesize delegate = _delegate;
@synthesize listLength = _listLength;
@synthesize dictionaryOfRecipes = _dictionaryOfRecipes;
@synthesize arrayOfRecipeNames = _arrayOfRecipeNames;
- (void)viewDidLoad
{
// ... code here
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
// ... other methods
UPDATE:
所以我決定將源代碼發佈到我的整個項目。我遇到了多個文件的問題,但是如果我將它修復爲一個,我很確定剩下的部分將會落實到位。
請關注文件BrowsePrivateRecipeViewController.m/.h.
這是最直接的問題。
再次感謝您的耐心和幫助。
真誠, 傑森
看看我的答案。 CodaFi是對的,但是如果他向你展示了一些代碼來修復它,那本來是很好的。我已經包含了一些簡單的代碼來幫助你開始。 –
我會假設他知道如何製作一個UIBarButtonItem,但我確實喜歡每隔一段時間在OP的正確方向上進行一點點推動。 +1 – CodaFi