-1

私は現在 Xcode を学ぼうとしていますが、長いチュートリアルを読むよりも、実際にやってみるほうがずっと好きです。そのため、Apple Developer Web サイトのサンプル コードをいくつか見て、コードの内外を学習しています。私は現在コアデータについて学んでいます ( https://developer.apple.com/library/ios/samplecode/iPhoneCoreDataRecipes/Introduction/Intro.html)しかし、私は問題に遭遇しました。レシピを入れるカテゴリを選択できる「カテゴリ」にリンクするボタンがあります。カテゴリは、私が知る限り、SQLite データベースに接続されています。ただし、このボタンを削除しようとしていますが、ボタンがコードのどこにあるのかわかりません。誰かがシミュレーターを介してボタンを見つけて削除する簡単な方法を知っているなら、私は本当に感謝します. )そしてそれを削除する方法を見てください、私は非常に感謝しています。どんな助けでも大歓迎です。ありがとう。

4

3 に答える 3

1

If you search the project for the word "Category", you can see that it's a section in a tableview inside RecipeDetailViewController:

Category search

This app-wide search function (which admittedly only scans code, not NIBs or Storyboards) is very useful.

This tells us that this is not part of the UI defined by the NIBs, but rather a UI generated from code (it's a section in the table view). As you can see from that code, that means that the section whose section number is equal to TYPE_SECTION results in the "Category" behavior. So search the code for all occurrences of TYPE_SECTION, and comment that out of the code. Because these section numbers are integral to the code (and have to start at zero), you have to adjust the constants that say:

#define TYPE_SECTION 0
#define INGREDIENTS_SECTION 1
#define INSTRUCTIONS_SECTION 2

and replace that with something like:

// #define TYPE_SECTION 0
#define INGREDIENTS_SECTION 0
#define INSTRUCTIONS_SECTION 1

This code, rather gracelessly, has hard-coding for the number of sections, too, so you'd probably have to fix that, too, namely, replacing:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 4;
}

with

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}

This is, at my quick investigation, what you need to do. There might be other things you'd have to do, too. If this was a UI element defined by a NIB or storyboard, the process of hunting it down is a little different (and sufficiently more cumbersome that I hesitate to go into it here ... the answer to that question is (a) not applicable to your immediate question of how to remove the "Category" section and (b) a detailed answer on searching NIBs would probably be more confusing than helpful; if you really want me to describe it I can, but it's probably not a good use of your time as you're just getting started).


Having said all of this, if you're looking to learn, diagnosing really old code might not be the first avenue I'd suggest.

I would, instead, suggest following some tutorials that walk you through the creation of your own test apps (e.g. Apple's "My First App" described in Jump Right In section of the Start Developing iOS Apps Today guide; or the Second or Third app that they describe in Where to Go From Here? section at the end of that guide.

Actually writing your own code (simplified by following along a tutorial like these) is going to be a heck of a lot more productive than trying to reverse engineer some old code (IMHO).

于 2013-09-02T02:13:01.933 に答える
0

インターフェイスはおそらく xib ファイルにあります。しかし、この方法で学習している場合は、より正式なアプローチが役立つ可能性がある問題に遭遇することを受け入れる必要があります。

于 2013-09-02T01:22:02.407 に答える