开发者

How does one change NIB's view Outlet at runtime? iPhone

开发者 https://www.devze.com 2023-03-30 16:57 出处:网络
Basically I\'m trying to run the free version of my app and the paid one off of the same code. The free one will have apps and in the nib file the main view will be a UIView, the paid one the main vie

Basically I'm trying to run the free version of my app and the paid one off of the same code. The free one will have apps and in the nib file the main view will be a UIView, the paid one the main view will be a UITableView.

The views work correctly when I set the view outlet under file owner in IB to which ever one I want, but I can't change that at runtime.

How could I change the view outlet property at runtime so I can do a check like if app is free then make UIView the view and if it is not free then UITableView is the view?

Thanks.

Edit: I was a bit vague so here is more detail. I want to get iAds to go throughout my app, so one banner that is shared, through a navigation controller with tableviews. I want the banner below the navigation bar and above the content of the view. In order to create the space for the banner I made the viewcontroller consist of a view and inside the view a tableview. I then resize the table view so its down to allow a banner. If I set the view outlet to the tableview the tableview takes the full screen and its normal. If I set the view outlet to the UIView, same nib, I get the tableview lowered with space to add the iAd. I was hoping I could do a check to change those o开发者_如何转开发utlets at runtime to either get fullscreen tableview or partial screen for iAd.

Sadly however, after I get this, I do not know how to share the iAd banner between tableviews.


A quick & dirty solution will be to put both the UIView & the UITableView in the same nib (one on top of the other) & hide one of them at runtime. So, you don't have to change the outlet, just get rid of the one that's not required.


Just make 2 nibs, which are each controlled by 2 different view controllers, and on launch, detect which version the app is, and load the appropriate view controller.

If you want to have only 1 view controller, that is fine as well. You can make 2 separate nibs which are each owned by the same view controller, and at launch, check which version the app is, and load the appropriate nib with -initWithNibName:bundle:. Hope that helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号