纯objective-c写的iOS App,增加新功能时可以用xib或者StoryBoard吗
大家讲道理
大家讲道理 2017-04-17 11:20:32
0
11
1430

我负责接手开发一个iOS App,之前这个产品已经在App Store架上了,没有用到xib, storyboard,所以的界面都是在objective-c代码画的(CGRectMake)。

现在我要给这个产品增加新的模块,新模块如果用xib或者StoryBoard,能和老的代码兼容吗,我问了团队内的两个同事,一个说可以,一个说不可以。

到底是可以不可以呢?

问题补充,老的代码里,所有界面都共用一个导航头,不同界面之间的跳转是这样写的:

[self.navigationController pushViewController:webv animated:YES];

在loadView方法中这样修改导航条上的文字:

self.title = @"关于我们";

我隐约记得那位说不可以的同事,就是说新的模块用xib/storyboard实现,pushViewController就不兼容了。只是隐约记得,不确信,如果有错,多半是我太菜听错,应该不是那同事的错-_-

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(11)
伊谢尔伦

Of course, each UIViewController is independent. If you add a new ViewController to implement the interface on the xib, it will not affect other places. If you change the previous Controller, just change the construction method when calling it. In fact, xib replaces what is done in the loadView method

巴扎黑

Compatible
For example, for a uiviewcontroller, if you don't add a xib at first, then add a xib, just change the associated class to the vc class. Also, you cannot override the loadview method and put the content of the initialized view elsewhere.
For example, if it is a uiview, define a view's xib, modify the class to your associated class, and then use it directly.

阿神

Absolutely, the project I am taking over now is a mixture of handwritten code, nib, and SB, and all supported methods are supported.

PHPzhong

Yes. For example, I added a new 用户模块 in the old project. This module uses StoryBoard to manage page flow. These VCs use UINavigationController as the container (this can be customized). The code that jumps from the current code to the user module is as follows:

- (void)goToUserModule {
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"User_iPhone" bundle:nil];
    UINavigationController *navigationVC = [sb instantiateInitialViewController];
    navigationVC.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:navigationVC animated:YES completion:nil];
}

As long as the module design is clear, I think it can basically be seamlessly connected.

阿神

xib obviously works, but I haven’t used StoryBoard to guess whether it works. In addition, using StoryBoard deployment target requires 5.0

Ty80

Yes.

In fact, xib just helps you (beautifully) do the work in (void) loadView. Similar to self.title = @"About Us"; this kind of attribute setting can be placed in the -(void)viewDidLoad method.

迷茫

xib definitely works

But why do this? There is a version conflict in xib and manual merge is fatal

洪涛

Owner, wouldn’t you know if you try it yourself?

PHPzhong

Of course, the storyboard will be clearer, but the size of the ipa will be larger

洪涛

This has a particularly practical technology, Xib modular development http://00red.com/blog/2016/07...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template