UIView、UIResponder、UIAlertView、UIActionSheet

code

通用

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    [_window release];
    ViewController *vc = [[ViewController alloc] init];
    self.window.rootViewController = vc;
    [vc release];
    return YES;
}
- (void)dealloc
{
    [_window release];
    [super dealloc];
}

UINavigationController的通用代碼

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.window makeKeyAndVisible];
    [_window release];
    ViewController *vc = [[ViewController alloc] init];
    UINavigationController *naVC = [[UINavigationController alloc] initWithRootViewController:vc];
    self.window.rootViewController = naVC;
    [naVC release];
    [vc release];
    return YES;
}

- (void)dealloc
{
    [_window release];
    [super dealloc];
}

UIView

動畫

// 從原來的位置移到新的位置,與原來的大小沒有關係

    [UIView animateWithDuration:5.5 animations:^{
            myView.frame = CGRectMake(50, 50, 70, 70);
        }];

property

  • hidden
  • self.automaticallyAdjustsScrollViewInsets 是ViewController的屬性,作用於第一個滾動視圖,默認YES,作用就是讓滾動視圖自動去適應尺寸

UIAlertView

    UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"提醒" message:@"鼠標點擊了" delegate:self cancelButtonTitle:@"好的" otherButtonTitles:@"哈哈", nil];
    myAlertView.alertViewStyle = UIAlertViewStyleSecureTextInput;
    [myAlertView show];
    [myAlertView release];

UIActionSheet

    UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:@"Actions" delegate:self  cancelButtonTitle:@"取消" destructiveButtonTitle:@"刪除" otherButtonTitles:@"猜", nil];
    myActionSheet.myActionSheetStyle = UIActionSheetStyleDefault;
    [myActionSheet showInView: self.view];
    [myActionSheet release];

UIResponder

Method

resignFirstResponder
becomeFirstResponder

ViewController初始化順序

-(id)initWithNibName:bundle:
-(void)loadView
-(void)viewDidLoad
-(void)viewWillAppear, viewDidAppear, viewWillDisappear, viewDidDisappear

發佈了26 篇原創文章 · 獲贊 0 · 訪問量 5239
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章