簡體   English   中英

UITextField選擇導致UITableVIew拉伸

[英]UITextField Selection is Causing UITableVIew to Stretch

我在UITextField上方有一個UITableView 當我選擇UITextFieldUITableView反復拉伸。 這是我的onViewLoad代碼:

- (void)viewDidLoad 
{
 [super viewDidLoad];
 self.title = @"Clock In Time";

     CALayer *layer= pickUpWeighCapacityList.layer;
 UIColor* uic = UIColorFromRGB(0x336600);
 CGColorRef* cgf = uic.CGColor;

  layer.borderWidth = 2;
  layer.borderColor = cgf;
  layer.cornerRadius = 10;
  layer.frame = CGRectMake(20.0f, 33.0f, 280.0f, 178.0f);

  pickUpWeighCapacityList.dataSource = self;
  pickUpWeighCapacityList.delegate = self;
  pickUpWeighCapacityList.tableHeaderView = nil;
  pickUpWeighCapacityList.tableFooterView = nil;

  pickUpWeighCapacityList.frame = CGRectMake(20.0f, 33.0f, 280.0f, 178.0f);

  i = 0;

  signOutTimeField.placeholder = @"Time to Clock Out of Work";
  picker = [[UIDatePicker alloc] init];
  signOutTimeField.inputView = picker;

  UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
        style:UIBarButtonSystemItemDone target:self action:@selector(doneEditing)];
  self.navigationItem.rightBarButtonItem = rightButton;
  [rightButton release];
  [picker release];
}

這是我具有視圖功能的代碼:

 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{
  // Return the number of sections.
  return 1;
}


 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{
  // Return the number of rows in the section.
  return 3;
}

如何使UITableView不拉伸? (iOS 4.3。XCode 3.2.6-不要判斷我)。

解決方案不是顯而易見的。 在您的viewDidLoad部分中,放置以下行:

 [[NSNotificationCenter defaultCenter] addObserver:self 
    selector:@selector(keyboardWillHide:) 
             name:UIKeyboardWillHideNotification object:nil];

然后在您的viewController包含以下代碼:

 - (void)keyboardWillHide:(NSNotification *)note 
    {
     [pickUpWeighCapacityList setFrame:
          CGRectMake(original-x-coord,original-y-coord,
                     original-length,original-width)];
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM