uitabbarcontroller + uitableviewcontroller +界面视图控制器

发布于 2024-08-20 10:11:00 字数 759 浏览 2 评论 0原文

我正在使用从 URL http:// www.iphonemusings.com/2009/01/iphone-programming-tutorial-creating.html 显示带有选项卡栏的初始屏幕,并在两个选项卡中都有表格视图。 在表视图委托中进行必要的更改后,它也会在单元格中显示文本。 现在我想在单击表视图时显示一个视图。我正在使用以下代码。

- (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 setText=@"Testing label"];
    [self.navigationController pushViewController:dv animated:YES];
    [dv release];
}

但它不显示任何文本。有人可以帮助我指出我的代码中有什么错误吗???

I'm using the code extracted from the URL http://www.iphonemusings.com/2009/01/iphone-programming-tutorial-creating.html to show initial screen with tab bar and having table view in both the tabs.
It is displaying the text in cells as well after taking necessary changes in table view delegate.
Now I want to show a view on click of table view. I'm using following code.

- (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 setText=@"Testing label"];
    [self.navigationController pushViewController:dv animated:YES];
    [dv release];
}

But it is not displaying any text. Can some one help me by pointing what mistake is in my code???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

笑梦风尘 2024-08-27 10:11:00

这能编译吗? [dv.label setText=@"测试标签"]; 不是 Objective-C。它应该是:

[dv.label setText:@"Testing label"];

Does this compile? [dv.label setText=@"Testing label"]; is not Objective-C. It should read:

[dv.label setText:@"Testing label"];
时光瘦了 2024-08-27 10:11:00

复制所有这些代码并将其粘贴到现有的位置即可工作。

- (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 setText=@"Testing label"];
    [dv release];
}

copy all this code and paste it at existing it will work.

- (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 setText=@"Testing label"];
    [dv release];
}
夏末的微笑 2024-08-27 10:11:00
-(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];  
    chats.title=@"Chats";

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

    contacts.title=@"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推送视图的代码。当您在表中选择一行时,它将显示一个新视图。

SignInViewController *signIn=[[SignInViewController alloc] initWithNibName:@"SignInViewController" bundle:nil];

[self.navigationController pushViewController:signIn animated:YES];
-(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];  
    chats.title=@"Chats";

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

    contacts.title=@"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];
}

Try this code. The code will display UITabBarController with two tabs. You can create table in both tabs. In didSelectRowAtIndexPath, write code for push a view using navigationController. When you select a row in the table it will display a new view.

SignInViewController *signIn=[[SignInViewController alloc] initWithNibName:@"SignInViewController" bundle:nil];

[self.navigationController pushViewController:signIn animated:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文