0

I have a picture(UIImageView) and button(UIButton).

In this view I use QuickDialogController because it has many Element of Quick dialog in this view.

I want to add picture(UIImageView) and button(UIButton) in Section(QSection) of this View.

How to add it.

This is my example code.

// test Add Image
-(void) addImageView
{
    image = [[UIImageView alloc] initWithFrame:CGRectMake(35, 60, 250, 250)];
    [image setImage:[UIImage imageNamed:@"image.jpg"]];
    [image setContentMode:UIViewContentModeScaleAspectFit];
    [self.view addSubview:image];
}

// test Add Button
-(void) addRotateButton
{
    button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(125, 350, 70, 40);
    button.backgroundColor = [UIColor lightGrayColor];
    [button setTitle:@"Rotate" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(onRotateButtonClicked:) forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:button];
}

Thank you.

guptha
  • 529
  • 1
  • 4
  • 9
Natthawat Sudsang
  • 523
  • 1
  • 5
  • 13

1 Answers1

0

I think there are two ways to do this. The easiest way is to add the view with button and imageview to the section header.

  # s is a Section, code is ruby motion
  s.headerView = UIView.alloc.initWithFrame [[0,0],[300,1]]
  image_view = UIImageView.alloc.initWithFrame CGRectMake(0, 0, 100, 100)

  s.headerView.addSubview image_view
  s.headerView.addSubview button 

If you would like to add it somewhere else in the section. I think you need to make a new class that inherits form QElement. Haven't done this yet.

Raymond
  • 3,630
  • 2
  • 19
  • 22