3

ダウンロードするファイルのリストを表示しているテーブルビューがあります。アクセサリボタンをタップすると、選択したファイルがダウンロードされます。詳細開示ボタンの画像を変更したい。出来ますか....?

そして、アクセサリビューで画像付きのボタンを使用した場合。このためのテーブルデリゲートメソッドはありますか...

4

3 に答える 3

4

回答 2: その場合、独自のメソッドを作成して呼び出すことができます。

int row=indexPath.row;

UIButton *trackImageOnMap=[[UIButton alloc] initWithFrame:CGRectMake(420, 9, 40, 50)];
[trackImageOnMap setImage:[UIImage imageNamed:@"track_map_icon.png"] forState:UIControlStateNormal];
int iId=[[self.imageId objectAtIndex:row] intValue];
NSLog(@"iId=%d",iId);
[trackImageOnMap setTag:iId];
[trackImageOnMap addTarget:self action:@selector(trackImageOnMapButtonTouched:)forControlEvents:UIControlEventTouchDown];
[trackImageOnMap setContentMode:UIViewContentModeScaleToFill];
//[cell setAccessoryView:trackImageOnMap];
[cell addSubview:trackImageOnMap];
于 2011-06-01T06:50:56.180 に答える
4

UIImageView を作成し、それを UITableViewCell の accessoriesView に割り当てることができます。

UIImageView *imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"accessoryIcon"]] autorelease];
cell.accessoryView = imageView;

accessoriesView のボタンが必要な場合は、基本的に同じです。

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"buttonImage"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(someAction:) forControlEvents:UIControlEventTouchUpInside];
button.tag = cell.indexPath;
cell.accessoryView = button;
于 2011-06-01T06:52:55.057 に答える
0

デフォルトのタイプを置き換えたい場合は、UITableViewCell を上書きして次のコードを使用できます。

- (void)setAccessoryType:(UITableViewCellAccessoryType)accessoryType
{
    if (accessoryType == UITableViewCellAccessoryDisclosureIndicator)
    {
        self.accessoryView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"YourNewImage.png"]] autorelease];
    }
    else
    {
        [super setAccessoryType:accessoryType];
    }
}
于 2012-08-02T16:50:17.587 に答える