2012-02-27 115 views
-2

我一直在使用Interface Builder和storyboard來製作我的應用程序,但是對於這個簽名捕獲API,一切都是在代碼中完成的。如何以編程方式在UIScrollView上添加對象/視圖?

我想實現它到我的應用程序,但我想不出如何添加UIView和按鈕到我的滾動視圖。

我知道它出現在我的視圖控制器中,但它根本沒有連接到scrollview;它顯示在上面。

這是我的代碼。

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    CGFloat padding = self.view.frame.size.width/15; 

    UIView *autoGraphView = [[[UIView alloc] initWithFrame:CGRectMake(padding, 300, 280, 160)] autorelease]; 
    autoGraphView.layer.borderColor = [UIColor lightGrayColor].CGColor; 
    autoGraphView.layer.borderWidth = 3; 
    autoGraphView.layer.cornerRadius = 10; 
    [autoGraphView setBackgroundColor:[UIColor whiteColor]]; 
    [self.view addSubview:autoGraphView]; 

    self.autoGraph = [T1Autograph autographWithView:autoGraphView delegate:self]; 
    [autoGraph setLicenseCode:@"4fabb271f7d93f07346bd02cec7a1ebe10ab7bec"]; 
    [autoGraph setShowDate:YES]; 
    [autoGraph setShowHash:YES]; 

    UIButton *clearButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    // init withFrame:CGRectMake (50, 300, 200, 60)]; 
    [clearButton setFrame:CGRectMake(padding, 480, 130, 30)]; 
    [clearButton setTitle:@"Clear" forState:UIControlStateNormal]; 
    [clearButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
    [clearButton addTarget:self action:@selector(clearButtonAction:) forControlEvents:UIControlEventTouchUpInside]; 
    [self.view addSubview:clearButton]; 

    UIButton *autoDone = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    // initWithFrame:CGRectMake (50, 300, 200, 60)]; 
    [autoDone setFrame:CGRectMake(150 + padding, 480, 130, 30)]; 
    [autoDone setTitle:@"Done" forState:UIControlStateNormal]; 
    [autoDone setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
    [autoDone addTarget:self action:@selector(doneButtonAction:) forControlEvents:UIControlEventTouchUpInside]; 
    [self.view addSubview:autoDone]; 
} 

回答

1

您需要的子視圖增加了滾動,如果你的視圖 - 控制的根本觀點是不滾動視圖,你需要訪問它這種或那種方式,通常通過一個IBOutlet,並加入他們,方式

相關問題