0

我有一张图片(UIImageView)和按钮(UIButton)。

在这个视图中我使用 QuickDialogController 因为它在这个视图中有很多快速对话框的元素。

我想在此视图的部分(QSection)中添加图片(UIImageView)和按钮(UIButton)。

如何添加它。

这是我的示例代码。

// 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];
}

谢谢你。

4

1 回答 1

0

我认为有两种方法可以做到这一点。最简单的方法是将带有按钮和图像视图的视图添加到节标题。

  # 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 

如果您想在该部分的其他位置添加它。我认为您需要创建一个继承表单 QElement 的新类。还没有这样做。

于 2014-04-14T09:33:33.110 回答