我已经在整个互联网上寻求帮助搜索所有,但很少有没有解决我的问题在眼前。 我,即时通讯试图让一个喘息的项目是很独特(UI是不完全遵循典型的规范)。
目前的开发环境:
下面是什么,我试图完成一个图 - 都在一个UIView控制器:
- UIView的是浅灰色的背景
- UITableView的1 - 这是一个静态(或它可以是动态的,这就是另一个挑战)的UITableView这将保持计算不同数值
- UITableView的2 - 这是用来存放每次运行时计算结果一个UITableView。
- 的UIImageView 1 - 这是一个计算出的图像的例子(我有想出)
我敢肯定经验的开发人员充分认识我的问题,并且还是要问什么IM约。 我的理解是静态的UITableView要求是在的tableview控制器,但我需要在同一时间,这意味着它必须是一个UIView中显示双方的UITableView的。
我可以使界面看起来我需要但它要通过IB试图编译和构建时的方式,我收到需要的UITableView的是一个UITableViewController,而不是一个UIView控制器内的错误。 我看到许多例子使用主详细布局,但唯一的要求是,此的UITableView需要该视图将被显示的时间的100%时。
所以基本上,我要求的方向......但一个代码示例从来没有伤害任何! 谢谢100X已经结束了!
-Jonathan
UITableViewController
仅仅是一个专门UIViewController
特别设计的全屏显示UITableView
秒。 它是(相当),相当于使用UITableViewController
子类或UIViewController <UITableViewDataSource, UITableViewDelegate>
子类来管理的tableview。
因此,即使UITableViewController
有一些更spiecialized行为(自动创建的UITableView如果不存在的话,会自动滚动它来显示键盘,将自己作为delegate
与dataSource
的独特UITableView
它管理等),你可以使用标准UIViewController
来管理UITableView
并成为其dataSource
来填补它。
这甚至可以管理没有采取全屏(一个实现代码如下一种方式UITableViewController
预计其view
属性直接是UITableView
它管理,而不是它的主视图或任何的子视图,并由此预计UITableView
采取全屏幕相反,使用UIViewController
,其具有UITableView
作为其的一个自定义尺寸的子类view
)
所以你的情况,你可以有一个UIViewController
有两个IBOutlets
,每个tableView
,以及独特UIViewController
可以是dataSource
(并delegate
双方的) UITableViews
。 这不是一个问题。 只是要小心,然后在您的数据源方法,如果你是为第一或第二返回数据来区分UITableView
每次喂正确的表。
@interface MyViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain) IBOutlet UITableView* masterTableView;
@property (nonatomic, retain) IBOutlet UITableView* detailsTableView;
@end
@implementation MyViewController
@synthesize masterTableView = _masterTableView;
@synthesize detailsTableView = _detailsTableView;
// Proper memory mgmt not shown here:
// - don't forget to set self.masterTableView and self.detailsTableView to nil in viewDidUnload
// - and to release _masterTableView and _detailsTableView in your dealloc method
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
UITableViewCell* cell;
if (tableView == self.masterTableView)
{
static NSString* kMasterCellIdentifier = @"MasterCell";
cell = [tableView dequeueReusableCellWithIdentifier:kMasterCellIdentifier];
if (!cell)
{
cell = [[[UITableViewCell alloc] initWithReuseIdentiier:kMasterCellidentifier] autorelease];
// do some configuration common to all your master cells
}
// configure the rest of your cell for each property that is different from one cell to another
}
else if (tableView == self.detailsTableView)
{
// Do exactly the same principle, but for the cells of your "details" TableView
}
return cell;
}