1

UITableViewヘッダーにUIBUttonを追加しましたが、機能していないようです。クリック可能ですが、IBActionをアタッチすると失敗し、何もしません。

私はオンラインで読んで、それをあなたのファイルの所有者に入れるのを見ましたが、それはできません。アクションを入れると、ファーストレスポンダーにのみ表示されます。

また、別のファイルに入れようとしましたが、入れても他のファイルにドラッグできません。

ファイル:

RootViewController.h RootViewController.m TableViewAppDelegate.h TableViewAppDelegate.m DetailViewController.h DetailViewController.m

RootViewController.h

@interface RootViewController : UITableViewController {
    NSMutableArray *listOfItems;
    Sqlite *database;
    NSTimer *myTimer;
    UITextView *myTextField;
}

- (IBAction)addAlbum;

RootViewController.m

#import "RootViewController.h"
#import "TableViewAppDelegate.h"
#import "DetailViewController.h"

@implementation RootViewController

// If a user adds a photo album
- (IBAction)addAlbum {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Add Gallery" message:@"this gets covered" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:@"Ok", nil];
myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12, 45, 260, 25)];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0, -80);
[alert setTransform:myTransform];
[myTextField setBackgroundColor:[UIColor whiteColor]];
[alert addSubview:myTextField];
[alert show];
[alert release];
[alert setTag:1];
}

どんな助けでも大歓迎です!ありがとう。

4

1 に答える 1

0

.xibからテーブルヘッダービューをロードする場合は、.xibの「ファイルの所有者」をUITableViewを提示するViewControllerサブクラスにし、ボタン内の目的のイベントをファイルの所有者内の目的のIBActionに接続します。tableView:viewForHeaderInSection:メソッドでプログラムでボタンを作成している場合は、ボタンオブジェクトで次のメソッドを使用して、ボタンにアクションを自分で接続する必要があります。

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents

編集:より具体的なアドバイスを提供できるように、tableView:viewForHeaderInSection:コードを投稿する必要があります。

于 2011-02-20T14:46:34.040 に答える