I adhere to the following code. Some of how my UIButton Extended class cannot show or hide UIImageView
My methods are called, and the image is not zero.
Here is the code:
@interface UILinkedImageButton : UIButton { IBOutlet UIImageView *linkImageView; } @property (nonatomic, retain) IBOutlet UIImageView *linkImageView; @end #import "UILinkedImageButton.h" @interface UILinkedImageButton () - (void)showImage; - (void)hideImage; @end ------------------------------------------------------------------------------------------------- @implementation UILinkedImageButton @synthesize linkImageView; - (void) dealloc{ [linkImageView release], linkImageView = nil; [super dealloc]; } - (id) initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if(self){ [self addTarget:self action:@selector(showImage) forControlEvents:UIControlEventTouchDown]; [self addTarget:self action:@selector(hideImage) forControlEvents:UIControlEventTouchUpInside]; [self addTarget:self action:@selector(hideImage) forControlEvents:UIControlEventTouchUpOutside]; } return self; } - (void)showImage { if(self.imageView){ NSLog(@"UILinkImageButton - showImage - currentStatus: %@", self.imageView); self.imageView.hidden = NO; [self.superview layoutIfNeeded]; } } - (void)hideImage { if(self.imageView){ NSLog(@"UILinkImageButton - hideImage"); self.imageView.hidden = YES; } } @end
As Thomas Müller notes in the commentary, I also think that actions should be in the controller.
, imageView, , , "linkImageView". , 'imageView' - readonly , UIButton, , linkImageView.
, .
, Swapnil
Source: https://habr.com/ru/post/1753840/More articles:С++ qt dll не в хорошей папке - c++Removing foreign key constraints, referential integrity, and hibernation - oracleGet Idictionnary From Ilist - c #Performance WPF - performancePHP sessions - user is not saved after logging in - phpMeetings messed up PHP - phpView oracle metadata about primary / foreign key constraints - sqlSession is rewritten in php - phpОтчет ReportViewer из DataTable - c#Устранение ошибок PHP и do/while - loopsAll Articles