Sunday, July 28, 2013

UITextFieldを縦方向に真ん中&TableViewのgroupedでUITextFieldを表示&UINavigationBarにボタン追加

UITextFieldを縦方向に真ん中にするのは以下のコード

    UITextField *field = [[UITextField alloc]initWithFrame:CGRectMake(10, 10, 200, 100)];
    field.text = @"sample";
    field.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    [self.view addSubview:field];

高さをUITableViewCellの高さに合わせればOK

-----------------------------------------------------

UINavigationbarの右にボタンを加える。storyboardではできないからね


    UIBarButtonItem *send = [[UIBarButtonItem alloc]initWithTitle:@"保存"
                                                            style:UIBarButtonItemStyleDone
                                                           target:self
                                                           action:@selector(saveSetting:)];
    self.navigationItem.rightBarButtonItem = send;


こんな感じかなー

No comments:

Post a Comment