0

Tab Bar Controller 및 일부보기 컨트롤러를 사용하여 응용 프로그램을 빌드해야합니다. 거의 모든 코드를 완료 했으므로 첫 번째 TableView (첫 번째 이미지)에서 viewcontroller를 푸시 할 때 문제가 발생합니다. 탭 표시 줄을 숨길 수는 있지만 내비게이션 막대를 상대적 뒤로 버튼으로 표시 할 수 없기 때문입니다.TabBar 컨트롤러 및 NavigationBar

저는 누군가가 저를 도울 수 있다면 IB (그리고 코드도) 구조를 만드는 법을 설명 할 수 있습니다. 단지 나머지 구조가 모두 완료 되었기 때문에 구조 만 설명해주세요. 감사! 먼저 창에서 jQuery과를하기 위해

image of the App structure

답변

0

, 당신은 당신의 .H 파일이있는 UITableViewController의 하위 클래스가 될 수 있도록하고하는 .m에 필요한 모든 방법을 추가해야 할 것

FirstViewController.h

@interface FirstViewController : UITableViewController { 

} 

@end 

FirstViewController.m

#import "FirstViewController.h" 


@implementation FirstViewController 

- (id)initWithStyle:(UITableViewStyle)style 
{ 
    self = [super initWithStyle:style]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (void)dealloc 
{ 
    [super dealloc]; 
} 

- (void)didReceiveMemoryWarning 
{ 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 

    // Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    // Uncomment the following line to preserve selection between presentations. 
    // self.clearsSelectionOnViewWillAppear = NO; 

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 
    // self.navigationItem.rightBarButtonItem = self.editButtonItem; 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 

- (void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 
} 

- (void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 
} 

- (void)viewWillDisappear:(BOOL)animated 
{ 
    [super viewWillDisappear:animated]; 
} 

- (void)viewDidDisappear:(BOOL)animated 
{ 
    [super viewDidDisappear:animated]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
#warning Potentially incomplete method implementation. 
    // Return the number of sections. 
    return 0; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
#warning Incomplete method implementation. 
    // Return the number of rows in the section. 
    return 0; 
} 

- (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... 

    return cell; 
} 

/* 
// Override to support conditional editing of the table view. 
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Return NO if you do not want the specified item to be editable. 
    return YES; 
} 
*/ 

/* 
// Override to support editing the table view. 
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (editingStyle == UITableViewCellEditingStyleDelete) { 
     // Delete the row from the data source 
     [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
    } 
    else if (editingStyle == UITableViewCellEditingStyleInsert) { 
     // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 
    } 
} 
*/ 

/* 
// Override to support rearranging the table view. 
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath 
{ 
} 
*/ 

/* 
// Override to support conditional rearranging of the table view. 
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Return NO if you do not want the item to be re-orderable. 
    return YES; 
} 
*/ 

#pragma mark - Table view delegate 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Navigation logic may go here. Create and push another view controller. 
    /* 
    <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; 
    // ... 
    // Pass the selected object to the new view controller. 
    [self.navigationController pushViewController:detailViewController animated:YES]; 
    [detailViewController release]; 
    */ 
} 

@end 

이제 첫 번째보기에서 테이블 뷰를 볼 수 있습니다. 그러면 다음 뷰를 밀어 넣어야합니다.

NextViewController *next = [[NextViewController alloc] initWithNibName:@"NextViewController" bundle:nil]; 
[next setTitle:@"Next View"]; 
[self.navigationController pushViewController:next animated:YES]; 
[next release]; 
+0

감사합니다. 지금이 모든 애플 리케이션에서 작동하지만 난이 있는지 모르겠습니다 ... –

0

NavigationViewController와 TabViewController는 모두 컨테이너 뷰 컨트롤러입니다. 따라서 계층 구조에 scence를 사용해야합니다.

이미지에 따르면, 사용해야하는 외부보기는 TabBarViewController입니다.

먼저 window 객체에 대한 rootviewcontroller로 만듭니다.

UITabBarController*tabCtrl = [[UITabBarController] alloc] init]; 
self.window.rootViewController = tabCtrl; 

초는 다음 tabbarcontroller에 추가하는 UINavigationController가 같은 제 controlelr 뷰를 만든다.

UINavigationController *firstCtrl = UINavigationController init... 
firstCtrl.rootViewController = firstTableViewController// this is the table view that you want to show on the first tab. 
관련 문제