xcode 4.2에서보기 기반 프로젝트를 만들었으며 다양한보기로 이동하기 위해 다중 레벨 탐색을 수행하려고합니다. 내 첫 번째 뷰 클래스는 ViewController 어디 테이블을 표시합니다. On 행을 클릭하면 tabbar가있는 다음 클래스로 이동합니다. 이것에는 3 개의 탭이 있습니다. 첫 번째 탭은 Class BuyerViewController를 사용합니다. 4 개의 버튼이 있습니다. 문제는 버튼을 클릭하면 다음 클래스를 푸시하지 않는다는 것입니다.xcode 4.2에서 iphone의 다단계 탐색
ViewController.m
- (void)viewDidLoad
{
[email protected]"Select County";
tView = [[UITableView alloc] init]; //tView is my table view object.
tView.frame=CGRectMake(0, 20, 320, 460);
[tView setDelegate:self];
[tView setDataSource:self];
[self.view addSubview:tView];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [countyArray count];
}
- (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];
}
cell.textLabel.text = [countyArray objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//This works fine and pushes to my next class to show the tabs.
ShowOptionInTab *showTabbar = [[ShowOptionInTab alloc] initWithNibName:@"ShowOptionInTab" bundle:nil];
[self.navigationController pushViewController:showTabbar animated:YES];
[showTabbar release];
}
ShowOptionInTab.m
-(void)loadView {
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor whiteColor];
self.view = contentView;
[contentView release];
BuyerViewController *buyerController = [[BuyerViewController alloc] init ];
SellerViewController *sellerController = [[SellerViewController alloc] init];
LenderViewController *lenderController = [[LenderViewController alloc] init];
[email protected]"Buyer";
sellerController.title = @"Seller";
lenderController.title = @"Lender";
UITabBarController *tabbarController = [[UITabBarController alloc] init];
tabbarController.view.frame = CGRectMake(0, 0, 320, 460);
[tabbarController setViewControllers:[NSArray arrayWithObjects:buyerController, sellerController,lenderController, nil]];
[buyerController release];
[sellerController release];
[lenderController release];
[self.view addSubview:tabbarController.view];
}
BuyerViewController.m
-(void)viewWillAppear:(BOOL)animated
{
UIButton *quickEstimateButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[quickEstimateButton addTarget:self action:@selector(getTagOfPressedButton:) forControlEvents:UIControlEventTouchUpInside];
[quickEstimateButton setTitle:@"QUICK ESTIMATE" forState:UIControlStateNormal];
quickEstimateButton.tag=1;
quickEstimateButton.frame = CGRectMake(10, 50, 150, 40.0);
[self.view addSubview:quickEstimateButton];
//more 3 buttons are added in same way
}
-(void) getTagOfPressedButton:(id)sender {
UIButton *getTagOfButton = (UIButton *)sender;
int buttonPressedTag = getTagOfButton.tag;
NSLog(@"TAG==========%d",buttonPressedTag);
if(buttonPressedTag==1)
{
NSLog(@"quick estimate pressed");
QuickEstimateViewController *q = [[QuickEstimateViewController alloc] init];
NSLog(@"nav====%@",self.navigationController); //This returns null.
[self.navigationController pushViewController:q animated:YES];
}
}
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
ViewController *overviewViewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:overviewViewController];
navigation.navigationBar.tintColor = [UIColor blackColor];
[overviewViewController release];
[self.window addSubview:[navigation view]];
[self.window makeKeyAndVisible];
}
,
QuickEstimateViewController가 표시되지 않는 이유는 무엇입니까?