Search Results

Search found 2 results on 1 pages for 'ggould75'.

Page 1/1 | 1 

  • Forward event from custom UIControl subclass

    - by ggould75
    My custom subclass extend UIControl (MyCustomUIControl) Basically it contains 3 subviews: UIButton (UIButtonTypeCustom) UIImageView UILabel All the class works great but now I want to connect some events generated from this class to another. In particular when the button is pressed I want to forward the event to the owner viewcontroller so that I can handle the event. The problem is that I can't figure out how to implement this behaviour. Within EditableImageView I can catch the touch event using [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside] but I don't know how to forward it inside of the buttonPressed selector. I also tried to implement touchesBegan but it seems never called... I'd like to capture the button press event from the viewcontroller in this way: - (void)viewDidLoad { [super viewDidLoad]; self.imageButton = [[EditableImageView alloc] initWithFrame:CGRectMake(50.0f, 50.0f, 80.0f, 80.0f)]; [imageButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:imageButton]; [imageButton setEditing:NO]; } This is my UIControl subclass initialization method: - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { [self setBackgroundColor:[UIColor clearColor]]; button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(0.0f, 0.0f, frame.size.width, frame.size.height); [button setImage:[UIImage imageNamed:@"nene_70x70.png"] forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:button]; transparentLabelBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"editLabelBackground.png"]]; transparentLabelBackground.hidden = YES; [self addSubview:transparentLabelBackground]; // create edit status label editLabel = [[UILabel alloc] initWithFrame:CGRectZero]; editLabel.hidden = YES; editLabel.userInteractionEnabled = NO; // without this assignment the button will not be clickable editLabel.textColor = [UIColor whiteColor]; editLabel.backgroundColor = [UIColor clearColor]; editLabel.textAlignment = UITextAlignmentLeft; UIFont *labelFont = [UIFont systemFontOfSize:16.0]; editLabel.font = labelFont; editLabel.text = @"edit"; labelSize = [@"edit" sizeWithFont:labelFont]; [self addSubview:editLabel]; } return self; } Thanks.

    Read the article

  • Extend TTPhotoViewController with custom TTPhotoView

    - by ggould75
    I have successfully integrated the three20 framework in my project, and I have extended the TTPhotoViewController to add some further functionality. Now I need to add some subviews to the TTPhotoView loaded by the TTPhotoViewController. In particular I would like to add that subviews after every TTPhotoView as been loaded. These subviews represents sensible area over the image so they should scale proportionally with the image. The user can tap a subview to get extra info about the image. I don't know how to implement this behavior. Should I extend the TTPhotoView and make sure that the TTPhotoViewController use this extended version instead of its TTPhotoView? Could someone point me to the right direction? Thank you

    Read the article

1