2014-01-08 39 views
0

我有一張圖片(UIImageView)和按鈕(UIButton)。如何將UIImageView添加到QuickDialog中的Qsection?

在此視圖中,我使用QuickDialogController,因爲它在此視圖中具有許多快速對話框元素。

我想在此視圖的Section(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]; 
} 

謝謝。

回答

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形式的新類。還沒有做到這一點。

相關問題