tableviewcontrollerでセルが選択されている場合、Firstviewcontrollerのイメージを更新する必要があります。 私のアプリケーションのナビゲーションベース。 Firstviewcontrollerにはボタンイベントが含まれています。ボタンをタップ私はテーブルビューを発射しています。テーブルビューでは、私はセルを選択し、左側のチェックマークを更新しています、それは正常に動作しています。私の質問は、セルが選択されていることを示すためにビューコントロール内の別のカスタムイメージを更新する必要があると同時にセルが選択されたときです。 With ref.テーブルビューの中でイメージセルを選択しました。 Firstviewcontrollerに表示する方法テーブルセルがコントローラ外で選択されている場合、カスタムイメージを更新する方法
here it is Appdelegate
@interface FertilityAppAppDelegate : NSObject <UIApplicationDelegate>
{
Fertility *updateImage;
}
@property (nonatomic, retain) Fertility *updateImage;
@implementation
@synthesize updateImage;
@interface Fertility : UIViewController
{
UIImageView *imgView;
FertilityAppAppDelegate *Appdelegate;
}
@property(nonatomic,retain) FertilityAppAppDelegate *Appdelegate;
@property (nonatomic, retain) UIImageView *imgView;
Viewcontroller for image update
@implementation Fertility
@synthesize imgView,Appdelegate;
- (void)viewDidLoad
{
[super viewDidLoad];
Appdelegate = (FertilityAppAppDelegate*)[[UIApplication sharedApplication] delegate];
}
- (void)changeImg:(UIImage*)image
{
imgView.image = image;
}
- (void)assignObjToTableViewClass
{
Appdelegate.updateImage = self;
}
Tableview controller
@interface Menstruation : UITableViewController
{
FertilityAppAppDelegate *Appdelegate;
}
@property (nonatomic, retain) FertilityAppAppDelegate *Appdelegate;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIImage *image = [UIImage imageNamed:@"bar.png"];
[Appdelegate.updateImage changeImg:image];
selectedRow = indexPath.row;
[self.tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
[[cell imageView] setImage:[UIImage imageNamed:@"Tick.png"]];
}
[[cell imageView] setHidden:YES];
if (indexPath.row == selectedRow)
{
[[cell imageView] setHidden:NO];
}
NSString *cellValue = [MenstruationArray objectAtIndex:indexPath.row];
cell.text = cellValue;
return cell;
}
。上記の画像はボタンの下に赤色のバーが付いたボタンです。
Firstviewcontrollerでこのボタンをクリックすると、月経テーブルビューで発生すると同時に、私はFirstviewcontrollerにイメージバーを更新する必要があります。
。 – vikingosegundo