-1

iOS ブック (IOS プログラミング) から IOS プロジェクトをコーディングしようとしています。

同様の質問が寄せられているのを見て、提供された解決策を試しましたが、まだ機能していません。

itemsViewController.m ファイルで、「不完全な実装です。修正方法がわかりません。他の同様のソリューションを使用しようとしましたが、まだ機能しません。

ItemsViewController.h と ItemsViewController.m の 2 つのファイルがあります。

//  ItemsViewController.h
//  Homepwner
#import <Foundation/Foundation.h>

@interface ItemsViewController : UITableViewController

{
    IBOutlet UIView *headerView;
}

- (UIView *)headerView;
- (IBAction)addNewItem:(id)sender;
- (IBAction)toggleEditingMode:(id)sender;

@end

//
//  ItemsViewController.m
//  Homepwner
//

//

#import "ItemsViewController.h"
#import "BNRItemStore.h"
#import "BNRItem.h"

@implementation ItemsViewController


- (id)init
{
    //Call the superclass's designated initializer
    self = [super initWithStyle:UITableViewStyleGrouped];
    if (self) {
        for (int i = 0; i < 5; i++) {
            [[BNRItemStore sharedStore] createItem];
        }

    }
    return self;
}

- (id)initWithStyle:(UITableViewStyle)style
{
    return [self init];
}

- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    return [[[BNRItemStore sharedStore] allItems] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Check for a reusable cell first, use that if it exists
    UITableViewCell *cell =
    [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];

    // If there is no reusable cell of this type, create a new one
    if (!cell) {
        cell = [[UITableViewCell alloc]
                initWithStyle:UITableViewCellStyleDefault
             reuseIdentifier:@"UITableViewCell"];
    }



    // Set the text on the cell with the description of the item
    // that is at the nth index of items, where n = row this cell
    // will appear in on the tableview

    BNRItem *p = [[[BNRItemStore sharedStore] allItems]
                  objectAtIndex:[indexPath row]];

    [[cell textLabel] setText:[p description]];

    return cell;
}



@end

助けてくれてありがとう。

4

3 に答える 3

2

製品のビルドログにアクセスすると、入力する必要のある不足しているメソッドを実際に確認できます。次に例を示します。

ビルドログには有用な情報があります

于 2013-02-02T05:06:07.840 に答える
1

インターフェイスでこれらのメソッドを宣言しました。

- (UIView *)headerView; 
- (IBAction)addNewItem:(id)sender;
- (IBAction)toggleEditingMode:(id)sender;

実装を提供していません。

于 2013-02-02T05:03:56.783 に答える
0

このコードは ItemViewController.m ファイルに追加する必要があります

  - (UIView *)headerView
{
    UIView *view = nil;
    return view;
}
 - (IBAction)addNewItem:(id)sender

 {

 } 
 - (IBAction)toggleEditingMode:(id)sender
{

}
于 2013-02-02T05:03:27.377 に答える