2

我有一个UITableView以上的UITextField。当我反复选择拉伸UITextField时。UITableView这是我的 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——不要评判我)。

4

1 回答 1

1

解决方案不明显。在您的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)];
    }
于 2013-01-05T00:11:36.943 回答