2013-12-20 76 views
0

我想用上部和下部製作iPad應用程序。按鈕將位於下部,點擊時只有中間部分會改變。我必須使用什麼樣的結構?我沒有標準窗口,標籤和按鈕的問題,但我不知道如何確保中間部分不會改變。3部分結構iPad應用程序

+0

你可以將你的屏幕分成3個UIView,頂部 - 中間和底部,並將按鈕放入適當的UIView。當你點擊一個按鈕時,你可以通過移動這些UIViews來改變視圖的一部分。 – Engnyl

回答

0

您可以在屏幕,第一屏幕上一級,第二屏幕中級,第三屏幕較低級別屏幕中使用3個UIViews,並且它會給出您想要的結果。

ViewController.h

#import <UIKit/UIKit.h> 

@interface ViewController : UIViewController 
@property (weak, nonatomic) IBOutlet UIView *view1; 
@property (weak, nonatomic) IBOutlet UIView *view2; 
@property (weak, nonatomic) IBOutlet UIView *view3; 
@property (weak, nonatomic) IBOutlet UIButton *btnSubmit; 
@property (weak, nonatomic) IBOutlet UILabel *lblClick; 
- (IBAction)btnClick:(id)sender; 
@end 

ViewController.m

@implementation ViewController 
int i=1; 
@synthesize view1; 
@synthesize view2; 
@synthesize view3; 
@synthesize btnSubmit; 
@synthesize lblClick; 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - View lifecycle 

    - (void)viewDidLoad 
    { 
     [super viewDidLoad]; 
      // Do any additional setup after loading the view, typically from a nib. 
    } 

    - (void)viewDidUnload 
    { 
     [self setView1:nil]; 
     [self setView2:nil]; 
     [self setView3:nil]; 
     [self setBtnSubmit:nil]; 
     [self setLblClick:nil]; 
     [super viewDidUnload]; 
     // Release any retained subviews of the main view. 
     // e.g. self.myOutlet = nil; 
    } 
    - (void)viewWillAppear:(BOOL)animated 
    { 
     [super viewWillAppear:animated]; 
    } 

    - (void)viewDidAppear:(BOOL)animated 
    { 
     [super viewDidAppear:animated]; 
    } 

    - (void)viewWillDisappear:(BOOL)animated 
    { 
     [super viewWillDisappear:animated]; 
    } 

    - (void)viewDidDisappear:(BOOL)animated 
    { 
     [super viewDidDisappear:animated]; 
    } 

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
    { 
     // Return YES for supported orientations 
     return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
    } 

    - (IBAction)btnClick:(id)sender 
    { 

     btnSubmit.tag = i++; 
     lblClick.text = [NSString stringWithFormat:@"%d",i]; 
     if(i%2 == 0) 
     { 
      view2.backgroundColor = [UIColor blueColor]; 
     } 
     else 
     { 
      view2.backgroundColor = [UIColor greenColor]; 
     } 
    } 
    @end 

上面的例子只是一個想法在1個視圖 - 控制與3次工作,在這個例子中取3次,其中第一視圖,只是空白,2視圖有顯示點擊查看按鈕的值3的標籤。並點擊按鈕上的標籤值是甚至然後view2背景顏色被改變ti藍色是vaqlue是奇數然後它變成綠色。在視圖3中有 有jus按鈕。

+0

你能舉個例子嗎?我想了解如何使用uiview類來做到這一點,謝謝 – bykrkc

+0

見編輯答案 –