touchesEndedに通知が来ない
objective-cで開発しております。
約6年前に作成し約4年前まで運用したプロジェクトを、Xcode12.5のバージョンで再度運用しようとしております。
サムネイル画像をタッチして処理を行う箇所があるのですが、
・iOS10.3.4のiPhone5端末ではtouchesEndedに通知が来ます。
・iOS14.8.1のiPad(第7世代)ではtouchesEndedに通知が来ません。
・iPhone12のエミュレーターでもtouchesEndedに通知が来ません。
のように挙動が違っております。
サムネイル画像は
- (void)setupLayer
{
imageLayer_ = [[UIImageView alloc]initWithFrame:self.bounds];
imageLayer_.frame = self.bounds;
videoLayer_ = [[UIImageView alloc]initWithFrame:self.bounds];
videoLayer_.frame = self.bounds;
duration_ = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 40, 15)];
duration_.backgroundColor = [UIColor clearColor];
duration_.frame = CGRectMake(30, 60, 40, 15);
[self addSubview:imageLayer_];
[self addSubview:videoLayer_];
[self addSubview:duration_];
}
- (void)setSelected:(BOOL)selected
{
thumbnail_.selected = selected;
//self.btImageView.userInteractionEnabled = YES;
if (selected) {
if (selectedCover_ == nil) {
selectedCover_ = [[ThumbnailViewCellSelectedCover alloc]initWithFrame:self.bounds];
selectedCover_.backgroundColor = [UIColor clearColor];
}
[self addSubview:selectedCover_];
} else {
[selectedCover_ removeFromSuperview];
}
}
- (id)init
{
self = [super initWithFrame:CGRectMake(0, 0, 75, 75)];
if (self) {
[self setupLayer];
}
return self;
}
- (void)dealloc
{
SAFE_RELEASE(imageLayer_);
SAFE_RELEASE(videoLayer_);
SAFE_RELEASE(duration_);
[thumbnail_ release];
[selectedCover_ release];
[super dealloc];
}
- (void)setThumbnail:(Thumbnail *)thumbnail
{
isSetup = YES;
SAFE_RELEASE(thumbnail_);
thumbnail_ = [thumbnail retain];
NSString *imageName = [PBApplicationDirectoryManager getFullFilePathWithFilePath:thumbnail.photo.thumbnail];
[self setSelected:thumbnail.selected];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if (!isSetup) {
return;
}
//どのcellがタップされたか伝える
NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
[params setValue:[NSString stringWithFormat:@"%ld", (long)thumbnail_.index] forKey:@"index"];
[params setValue:[NSString stringWithFormat:@"%@", ((thumbnail_.selected == YES)?@"YES":@"NO")] forKey:@"selected"];
[params setValue:self forKey:@"thumbnailView"];
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
NSNotification *notification = [NSNotification notificationWithName:ThumbnailTouchEvent object:self userInfo:params];
[center postNotification:notification];
[params release];
}
というようなコードで作成しております。
iOS10.3.4のiPhone5端末で動いているのでコードの問題ではなく、OSのバージョン違いによる設定が必要なのだとは思うのですが
何を追加したらよいのでしょうか
よろしくお願い致します。
0 likes