我想在我的应用程序中有一个相对较小的表视图。但我似乎没有运气,因为桌面视图占据了整个屏幕。表视图占用整个视图而不是输入宽度和高度
-(void)viewDidLoad{
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 20.0, 60.0) style:UITableViewStylePlain];
self.view = tableView;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyCellIdentifier = @"MyCellIdentifier";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:MyCellIdentifier];
if(cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyCellIdentifier];
}
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
}
它是否在UIViewController中? – 2013-04-05 19:07:31