iPad未显示以编程方式创建的UITable
我有一个iPad应用程序,它没有显示以编程方式创建的表。我的代码中哪里有错误或缺少什么 ViewController.hiPad未显示以编程方式创建的UITable,ipad,uitableview,Ipad,Uitableview,我有一个iPad应用程序,它没有显示以编程方式创建的表。我的代码中哪里有错误或缺少什么 ViewController.h 表是否必须在没有数据的情况下显示,就像要显示的数组一样?我用coredata中的数据测试了它,但没有显示出来,所以我先做了这个简单的测试,以编程方式显示uitable。您是否尝试过在添加子视图后在视图的末尾添加[[self-view]setNeedsDisplay]您的框架看起来有点不对劲。您正在将该视图作为子视图添加到self.view尝试只使用这些维度,或者只使用CGRe
表是否必须在没有数据的情况下显示,就像要显示的数组一样?我用coredata中的数据测试了它,但没有显示出来,所以我先做了这个简单的测试,以编程方式显示uitable。您是否尝试过在添加子视图后在
视图的末尾添加[[self-view]setNeedsDisplay]
您的框架看起来有点不对劲。您正在将该视图作为子视图添加到self.view
尝试只使用这些维度,或者只使用CGRectMake(0,0200200)
查看是否有显示。如果是这样,那么您已经证明当前维度将其置于边界之外,并且它将被剪裁。最终会跟随duhh
而且它表现得很好!!,;) 嗨,tnx,不,按照你的建议做了,但也不起作用:(,,我没有setNeedsDisplay,我可以不显示它吗?,还有什么其他的东西吗?你不需要它,它可以安全地删除。只是想看看它是否起到了作用。嗨,更改了CGRectMake(0,02000)但是仍然没有显示,可能是什么?因为您添加了自动重定尺寸任务
?
#import <UIKit/UIKit.h>
@interface deleteViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>{
UITableView *listTable;
}
@property (nonatomic, retain) UITableView *listTable;
//@property (nonatomic, retain) IBOutlet UITableView *listTable;
@end
#import "deleteViewController.h"
@implementation deleteViewController
@synthesize listTable;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
listTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 200, 200) style:UITableViewStylePlain]; //changed THANKS!!,
listTable.delegate = self;
listTable.dataSource = self;
//listTable.allowsSelection = TRUE;
[listTable reloadData];
//listTable.backgroundColor = [UIColor clearColor];
[listTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[self.view addSubview:listTable];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
//cell.textLabel.text = [yourarray objectAtIndex:indexPath.row];
return cell;
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(100, 100, 200, 200)
style:UITableViewStylePlain];
tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
tableView.delegate = self;
tableView.dataSource = self;
[tableView reloadData];
//self.view = tableView;
[self.view addSubview: tableView];
[tableView release];