私はこの問題にかなり長い間苦労してきました。多分あなたは私を助けることができます。だから私はプログラムでシンプルなUITableViewを使って基本的なUINavigationControllerを作成したいと思います。
たとえば、UITableViewには「色」に関する情報が含まれます。アイテムリストは、「黄色」、「オレンジ」、「緑」、「紫」のようになります。
あなたが私がこれを正しくするのを手伝ってくれるなら、私は本当に本当に幸せです。
私はこの問題にかなり長い間苦労してきました。多分あなたは私を助けることができます。だから私はプログラムでシンプルなUITableViewを使って基本的なUINavigationControllerを作成したいと思います。
たとえば、UITableViewには「色」に関する情報が含まれます。アイテムリストは、「黄色」、「オレンジ」、「緑」、「紫」のようになります。
あなたが私がこれを正しくするのを手伝ってくれるなら、私は本当に本当に幸せです。
これを試して:
@interface MyViewController: UITableViewController {
NSArray *data;
}
@end
@implementation MyViewController
- (id)init
{
if ((self = [super init]))
{
data = [[NSArray alloc] initWithObjects:@"Red", @"Green", @"Blue", nil];
}
return self;
}
- (void)dealloc
{
[data release];
[super dealloc];
}
- (int)tableView:(UITableView *)tv numberOfRowsInSection:(int)s
{
return [data count];
}
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)ip
{
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@"CELLID"];
if (!cell) cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault identifier:@"CELLID"] autorelease];
cell.textLabel.text = [data objectAtIndex:ip.row];
return cell;
}
@end
次のように使用します。
MyViewController *ctrl = [[MyViewController alloc] init];
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:ctrl];
[ctrl release];
等