简体   繁体   English

TabBarController setSelectedIndex-将调用哪个委托方法

[英]TabBarController setSelectedIndex - Which delegate method will be called

I would like to know when we are setting setSelectedIndex for uitabbbarviewcontroller, Which delegate method will be called. 我想知道何时为uitabbbarviewcontroller设置setSelectedIndex,将调用哪个委托方法。

In my app, i have list of songs to purchase.when user taps buy button for any song, i will show the downloading tab.for that i am setting [self.tabBarController setSelectedIndex:3]; 在我的应用中,我有要购买的歌曲列表。当用户点击任何歌曲的“购买”按钮时,我将显示下载选项卡。为此,我正在设置[self.tabBarController setSelectedIndex:3]; there i am showing the song details and progressview that how much is downaloded etc. 我在那儿展示了歌曲的详细信息和progressview,其中有多少已减价等。

This is fine upto this.in the meanwhile of downaloding poem the user can go and tap buy another poem. 到目前为止,这还不错。在下调诗歌的同时,用户可以去点击购买另一首诗歌。 here i want to reload the tableview.but i dont know in which delegate method i should call reload data for tableview. 在这里我想重新加载tableview。但是我不知道我应该在哪种委托方法中调用tableview的重新加载数据。

I tried viewwillappear and viewdidappear. 我尝试过viewwillappear和viewdidappear。 but these are not called. 但是这些没有被调用。 So please tell me which delegate method will be called. 因此,请告诉我将调用哪个委托方法。

Thanks a lot 非常感谢

override UITabBarController setSelectedIndex: 覆盖UITabBarController setSelectedIndex:

-(void)setSelectedIndex:(NSUInteger)selectedIndex
{
    //must call super function. 
    [super setSelectedIndex:selectedIndex];

    [self myMethod];
}

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    [self myMethod];
}
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController;

is called only when user taps it, when you programmatically set this, it is not called. 仅在用户点击时调用,而以编程方式设置时则不调用。 You can fire a custom delegate method or notification as soon as you do it programmatically and do what ever you need to do... 您可以通过编程方式立即执行自定义的委托方法或通知,并执行所需的操作...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM