小编Phi*_*ges的帖子

UITabbarController以编程方式更改栏项目标题

我正在尝试以编程方式更改我的应用中的标签栏项目的名称.

在我的故事板中,我将UITabBarController设置为初始视图,层次结构如下:

UITabBarController - > UINavigationController - > UITableViewController - >详细信息视图控制器

要更改条形项的标题,您需要更改条形项的UINavigationController标题.在IB中一切运行良好,但我需要本地化我的应用程序,我动态执行(没有重新启动应用程序),每次启动应用程序时,IB中给出的标题都会设置,标题不会更改为本地化标题,直到我点击条形项目.

在我各自的UITableViewControllers中,我设置了标题,self.title = localized title;并且运行良好.但我想让应用程序在启动时更改条形项目标题,直到我点击它们.

我已经在这里看了关于这个问题的帖子,并尝试了这些建议,但是条形项目的标题总是设置为IB的值.我也在下面尝试了这个代码,但是它只在启动时设置了所选的条形项:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Select the desired tab of our initial tab bar controller:
    UITabBarController *tabBar = (UITabBarController *)self.window.rootViewController;
    tabBar.selectedIndex = 1;
    tabBar.navigationController.title = @"Item 2";

    [(UITabBarItem*)[self->tabBarController.tabBar.items objectAtIndex:1] setTitle:@"Item 2"];

    // Override point for customization after application launch.
    return YES;

}
Run Code Online (Sandbox Code Playgroud)

items tabbar uitabbarcontroller

3
推荐指数
1
解决办法
3938
查看次数

在 URL Objective-C 处获取文件大小

我正在寻找一种方法来获取 NSURL 地址中特定文件的文件大小。这是我尝试过的,但它总是在日志输出中返回“0”:

NSString *url = @"http://www.examplesite.com/file01.zip";

unsigned long long fileSize1 = [[[NSFileManager defaultManager] attributesOfItemAtPath:[url lastPathComponent] error:nil] fileSize];
NSLog(@"size of %@ in bytes === %llu", [url lastPathComponent], fileSize1);
Run Code Online (Sandbox Code Playgroud)

size file nsurl

1
推荐指数
1
解决办法
1400
查看次数

标签 统计

file ×1

items ×1

nsurl ×1

size ×1

tabbar ×1

uitabbarcontroller ×1