私は、flickrの写真を取得するiPhoneアプリの既存のxcodeプロジェクトを使用しています。ユーザーがお気に入りの配列に写真を追加できるようにお気に入りボタンを追加したいのですが、これまでプログラムでUIオブジェクトを作成したことがないため、困惑しています。
これが私のボタンのコードですが、どのようにメソッドを追加しますか?また、このメソッド定義はどこに行きますか?
// Create favorites button
UIButton *favButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
favButton.frame = CGRectMake(200, 50, 100, 50);
[favButton setTitle:@"Favorite" forState:UIControlStateNormal];
favButton.backgroundColor = [UIColor clearColor];
[favButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
UIImage *buttonImageNormal = [UIImage imageNamed:@"blueButton.png"];
UIImage *strechableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[favButton setBackgroundImage:strechableButtonImageNormal forState:UIControlStateNormal];
UIImage *buttonImagePressed = [UIImage imageNamed:@"whiteButton.png"];
UIImage *strechableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[favButton setBackgroundImage:strechableButtonImagePressed forState:UIControlStateHighlighted];
[favButton addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:favButton];
addTargetメソッドはメソッドを追加する方法ですか?ボタンをクリックするたびに、xcodeに戻り、main.mファイルが表示され、次のコード行が強調表示されるためです。
int retVal = UIApplicationMain(argc, argv, nil, nil);
申し訳ありませんが、私はこれにまったく慣れていません。プロジェクトには次のファイルがあります。JSONFlickrAppDelegate.hJSONFlickrAppDelege.mJSONFlickrViewController.hJSONFlickrViewController.m ZoomedImageView.h ZoomedImageView.m
これが私が取り組んでいるxcodeプロジェクトです:http: //compsci.cis.uncw.edu/~pattersone/courses/275/resources/JSONFlickrPart3.zip