xib

How to change dynamically the xib of a UIVIewController

ぃ、小莉子 提交于 2019-12-06 05:54:28
I have an UIVIewController "controller1" for instance. This controller is instanciated with initWithNibName... with "file1.xib". I want to dynamically change the xib file of my "controller1" to "file2.xib" To resume : "controller1" <-> "file1.xib" and I want to dynamically have : "controler1" <-> "file2.xib" How can I do this ? Hope I was clear. When you want to change views in a UIViewController just just use this code: NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"file2" owner:self options:nil]; UIView *aView = [nibObjs objectAtIndex:0]; self.view = aView; I have two responses : 1

Xib for iPhone and iPad

Deadly 提交于 2019-12-06 05:24:50
问题 I have a Xib for iPhone and I need a similar view for iPad, only iPad size. What is the best way of doing this? Can you put both views in the same Xib and somehow specify which one is shown? Or do I need to be make 2 Xib files and 2 classes? 回答1: I ended up using 1 class. I set the file owner of both XIB files to this same class. I just used the name of the XIB file So I have 2 xibFiles, iPadXib.xib and iPhoneXib.xib NSString *nibFileName = (iPadVersion) ? @"iPadXib" : @"iPhoneXib";

Slider view for iOS

我们两清 提交于 2019-12-06 03:26:40
Can someone help me with this scenario? *There is a button, which when tapped, slides opens up a UIView, with the tapped button still to its left. *This button when tapped again, makes the UIView slide back. What you describe is easy. Let's call the view that slides in from the right a drawer ("drawerView"). Set up the drawer view as a child view of your view controller's main view. Make that "drawer" view a container view. Put everything you want inside it. (Your text view, buttons, etc.) Also put your button inside this view. Connect that button to an action "slideDrawer" in your view

Autoresize not working in xib

半腔热情 提交于 2019-12-06 03:16:01
问题 I made simple design in .xib , deployment target for my app is iOS 5 My view doesn't resizes, when i run my app in simulator or device. here is snapshot of my .xib file.. When i try to run my app in simulator, it runs properly in the simulator of 4", but it does not resizes, when i run my app in the simulator of 3.5". Autoresize subview property is checked. Here is snapshot of my Simulaotrs , first screenshot is for 3.5" and second for 4".. Thanks in advance. 回答1: if you want to autoresize

Which “Top-Level Objects” is Apple talking about in the Memory Management Programming Guide?

≯℡__Kan透↙ 提交于 2019-12-06 01:59:37
问题 In the Memory Management Programming Guide for Cocoa Apple talks about Top-Level Objects. They say, that I need an Outlet for each of them. If there are any top-level objects you do not store in outlets, however, you must retain either the array returned by the loadNibNamed:owner:options: method or the objects inside the array to prevent those objects from being released prematurely. So what exactly do they mean with "top-level object"? I would say they talk about the root view and window.

How to write init method for custom UIView class with xib file

寵の児 提交于 2019-12-06 01:20:09
I have created simple view using interface builder. This view has one label. Do you know how to create init method for this class ? I wrote my own version but I am not sure that it is correct or not. @interface AHeaderView () @property (nonatomic, weak) IBOutlet UILabel *descriptionLabel; @end @implementation AHeaderView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // add subview from nib file NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"AHeaderView" owner:nil options:nil]; AHeaderView *plainView = [nibContents lastObject]; plainView

What is the difference between “Inferred” and “Freeform” in Xcode Storyboard?

旧时模样 提交于 2019-12-05 23:11:30
问题 I have a custom view which needs to be displayed on all the iPhone devices(4, 4S, 5, 5S, 6 and 6 Plus). When creating the custom view XIB, I have mentioned it as "Inferred" but it is not resizing for iPhone 6 and iPhone 6 Plus devices. I am not able to figure out the issue. I am confused on what would be actual differences between "Inferred" and "Freeform". Can someone please explain the differences? 回答1: Inferred resizes the scene according to its parent scene. For example if you have a

iOS Instagram Tags Text Layout? How Is It Done?

China☆狼群 提交于 2019-12-05 21:58:16
I've always been curious how instagram gets it's tags to layout fluidly and wanted to know what goes behind this functionality? To me, it seems like they're using UIButton's and just calculating placement of the buttons line by line? Is that right? Or is there a simpler method of doing it without having to manual calculate the placement of each tag line by line / or side by side given that multiple tag's width's fit together? Or, are they using NSAttributedStrings? Any ideas? Here's an example of the layout I'm referring to. Here is a simplified way to do it using UITextView and

Best approach to change Xib direction programmatically

岁酱吖の 提交于 2019-12-05 21:37:49
I have an app that has a settings page in which the user can change the app's language. Eventually, the direction of the xibs will change. To explain a bit more, if the language is English for example, the direction will be LTR; However if it's Arabic, it will be RTL. Question What is the best approach to achieve this? Approaches tried with issues NSUserDefaults : When setting the language to "ar-SA", the direction changes successfully but only when it's called in the main class. When I do it in runtime, the app must be restarted to take effect. Even if there's a way to restart the app, it's

Packaging a Bundle with a static library

≯℡__Kan透↙ 提交于 2019-12-05 21:01:16
问题 I have a static library that includes some xibs. These will basically be the same across projects. I'd like to include the xibs as part of the library. I can include their veiwcontrollers, reference these controllers in the calling project but then there isn't a xib to load. When I right click the xib in the library project, it can't be part of the target. I thought about creating a CFPluginBundle but that creates a new project. I'd loose all of my IBOutlet and IBAction references. What is