2012-08-25 27 views
0

我将非常感谢任何帮助 - 我一直在试图弄清楚如何在嵌套的UITABLEVIEW中更改tabbarcontroller上的选项卡,就像在RayWenderlich.com的教程中一样像滚轮http://www.raywenderlich.com/4723/how-to-make-an-interface-with-horizontal-tables-like-the-pulse-news-app-part-2脉冲,但我真的陷入了困境。我正在使用故事板和xcode 4.4更改wenderlich教程中的Tabbarcontroller选项卡脉冲uitableview

我是几个星期的xcode的全新手机,所以我很抱歉如果这是一个新手问题。我已经得到了嵌套的水平桌面正常工作,因为上面的链接图像,但我想使用图像切换到新标签,但不能 - 我认为这是因为tableview是嵌套的,所以我找不到正确引用层次结构中的tabbarcontroller。

如果我使用ArticleListViewController.m didselect其中教程包含注释似乎建议插入导航代码将生成一个NSLog输出和更改选项卡确定,但只使用图像上方的一个小薄条(我偶然发现),但但图像没有任何反应。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     // Navigation logic may go here. Create and push another view controller 

    //THIS SELECTS WHEN CLICK THINSTRIP JUST ABOVE BUTTONS 
    NSLog(@"ARTICLELISTVIEWCONTROLLER check didSelect: %u", self.tabBarController.selectedIndex); 

    self.tabBarController.selectedIndex = 2; 
     } 

内Horizo​​ntaTableCell.m下面的代码,当我点击的实际图像,但我想不通的tabbarcontroller参考,让我改变标签更适当地产生的NSLog输出。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    { 

    //the following line just generates an Error as follows: Property tabBarController not found on object of type 'HorizontalTableCell *' 

    self.tabBarController.selectedIndex = 2; 

    NSLog(@"HORIZONTALTABLECELL DIDSELECT"); 

    } 

我看了看周围的方式,但无法弄清楚。发现使用appdelegate的提到,但不知道如何做到这一点。不能发布故事板图像作为新用户,但有一个带有4个导航控制器的tabbarcontroller出来 - 第一个是ArticleListViewController菜单,其他每个都是viewcontrollers - 我希望把WebView加载链接/本地页面取决于选择的菜单和其他用于关于屏幕和其他当前空白的屏幕。

请帮忙!

谢谢!

回答

0

我猜你有tabBarController作为你的应用程序委托中的属性?

你可以达到你的应用程序代理: [[UIApplication sharedApplication] delegate]

演员,为您的应用程序代理类和编译器不会警告你在标签栏控制器深远。像这样:

((YourAppDelegate *) [[UIApplication sharedApplication] delegate]).tabBarController.selectedIndex = 2; 

至于tableview委托方法,ArticleListViewController听起来像你想要的地方。这些单元应该只是愚蠢的观点,最多只有少量的表示逻辑。如果它没有被调用,请确保已经将其设置为表视图的委托(在界面构建器中,如果您遵循了所链接的教程)。

+0

谢谢,我想我已经明白了!经过一段时间的拖网捕鱼工作。从字面上花了整整一天,大部分时间试图解决它! AppDelegate * appdelegate1 =(AppDelegate *)[[UIApplication sharedApplication] delegate]; appdelegate1.TBcontroller.selectedIndex = .... – elricardo