pepe
pepe

Reputation: 9909

How to programatically add an icon overlay in iOS?

When a user views the detail for a post that contains a video, I'd like to show a 'play' icon overlaying the post thumbnail.

I've tried this but it doesn't compile:

    if ([postType isEqualToString:@"video"]) {
        UIImageView *videoIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vicon"]];
        videoIcon.frame = CGRectMake(5, 10, 35, 35);
        [self addSubview:videoIcon]; 
    }

and the error given is:

No visible @interface declares the selector addSubview

Does anyone know how to make this work?

The above code is within my DetailViewController.m. The overall structure is that of a UICollectionView with Master/Detail interfaces.

Upvotes: 2

Views: 728

Answers (1)

James Webster
James Webster

Reputation: 32066

Perhaps

[self.view addSubview:videoIcon];

if self is not a subclass of UIView then addSubview is unlikely to be defined

Upvotes: 8

Related Questions