2010-02-09 10 views
0

URL http://www.iphonemusings.com/2009/01/iphone-programming-tutorial-creating.html에서 추출한 코드를 사용하여 탭 표시 줄이있는 초기 화면을 표시하고 두 탭에 모두 테이블보기를 표시합니다. 테이블 뷰 대리자에서 필요한 변경 사항을 수행 한 후 셀에 텍스트도 표시합니다. 이제 테이블보기 클릭에 대한보기를 표시하려고합니다. 다음 코드를 사용하고 있습니다.uitabbarcontroller + uitableviewcontroller + uiviewcontroller

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    Latest* evnt = (Latest*)[latestArray objectAtIndex:indexPath.row]; 
    NSString* url = [evnt URLLink]; 
    DetailedView* dv = [[DetailedView alloc] init]; 
     [dv.label [email protected]"Testing label"]; 
    [self.navigationController pushViewController:dv animated:YES]; 
    [dv release]; 
} 

하지만 텍스트가 표시되지 않습니다. 어떤 사람이 내 코드에 실수가 무엇인지 알려줌으로써 나를 도울 수 있습니까 ???

답변

1

이 컴파일됩니까? [dv.label [email protected]"Testing label"];은 Objective-C가 아닙니다. 읽어야합니다

[dv.label setText:@"Testing label"]; 
0
-(void)viewDidLoad 
{ 
    UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; 
    contentView.backgroundColor = [UIColor whiteColor]; 
    self.view = contentView; 

    ChatsViewController *chats=[[ChatsViewController alloc] initWithNibName:@"ChatsViewController" bundle:nil]; 

    UINavigationController *searchNav = [[UINavigationController alloc] initWithRootViewController:chats]; 
    [email protected]"Chats"; 

    ContactsViewController *contacts=[[ContactsViewController alloc] initWithNibName:@"ContactsViewController" bundle:nil]; 
    UINavigationController *contacts1 = [[UINavigationController alloc] initWithRootViewController:contacts]; 

    [email protected]"Contacts"; 

    UITabBarController *tabBarController = [[UITabBarController alloc] init]; 
    tabBarController.view.frame = CGRectMake(0, 0, 320, 460); 

    [tabBarController setViewControllers:[NSArray arrayWithObjects:searchNav,contacts1,accounts1,settings1, nil]]; 

    [self.view addSubview:tabBarController.view]; 
} 

이 코드를 사용해보십시오. 코드에는 두 개의 탭이있는 UITabBarController이 표시됩니다. 두 탭 모두에서 표를 작성할 수 있습니다. didSelectRowAtIndexPath에는 navigationController을 사용하여 뷰를 푸시하기위한 코드를 작성하십시오. 표에서 행을 선택하면 새로운보기가 표시됩니다.

0

이 코드를 모두 복사하여 붙여 넣기하면 작동합니다.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    Latest* evnt = (Latest*)[latestArray objectAtIndex:indexPath.row]; 
    NSString* url = [evnt URLLink]; 
    DetailedView* dv = [[DetailedView alloc] init]; 

    [self.navigationController pushViewController:dv animated:YES]; 
[dv.label [email protected]"Testing label"]; 
    [dv release]; 
} 
관련 문제