nib

How can I programmatically access UI elements in a NIB without 'wiring' them?

ε祈祈猫儿з 提交于 2019-12-04 04:14:28
I'm contemplating writing some helper functions to make it easier to do simple changes to the UI elements in my iPhone NIB. Mainly - I want to access a UILabel, or other element, via its Name in Interface Builder. Is this possible? Is there a smarter approach? Example Say I want to make a super simple iPhone app that displays 'Hello World'. I start a new project and then open the NIB and drag a UILabel into my view and give it a 'Name' of 'LblMain'. Now, presuming that I've included my handy helper function, I'd like to assign the label some new text something like this: [helper setText:@

Could not load NIB in bundle - inspiration needed

社会主义新天地 提交于 2019-12-03 21:58:48
I'm currently seeing this error: MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Could not load NIB in bundle: 'NSBundle </Users/imac/Library/Application Support/iPhone Simulator/5.0/Applications/5D8B4B51-9FB2-4331-BFEB-B1A0AC77DF42/Tutorial.app> (loaded)' with name 'MyFirstView' I've looked through lots of other questions like: NSInternalInconsistencyException Could not load nib in bundle Could not load NIB in bundle and lots of others But I can't see that any apply here - they are mainly about file naming issues and my Nib does appear to be in

Cocoa - Display xib on another xib

跟風遠走 提交于 2019-12-03 16:13:06
Can anyone tell me how (or direct me to info on) displaying a .xib (nib) on another .xib (nib). How ever I wish to place it so I can programically move it around the main nib sort of like this (which obviously doesn't work) - (void)drawRect:(NSRect)dirtyRect { NSRect customView = NSMakeRect(pos1, pos1, 200, 100); [[NSBundle mainBundle] loadNibNamed:@"secondXib" owner:self]; NSRectFill (customView); } And I wish to do this for Mac OS X (Not iPhone). (By the way using xCode 4 incase it makes a difference) You can easily load a view from another nib using NSViewController . In your nib you should

Load custom UIView with XIB from a View Controller's view using IB

一曲冷凌霜 提交于 2019-12-03 14:39:49
I have a custom UIView ( MyCustomUIView ) which is built using Interface Builder. I'd like to place this custom view in MyViewController 's view, which is also designed using IB. I've placed an UIView as a subview in MyViewController 's XIB and set it's class to MyCustomUIView . The problem is, when I run the code, only a blank view appears. (When I instantiate MyCustomUIView in code, it displays well.) I'm only overriding the initWithFrame: method the following way in MyCustomUIView.m : - (id)initWithFrame:(CGRect)frame { [[NSBundle mainBundle] loadNibNamed:@"MyCustomUIView" owner:self

Views are mirrored in RTL languages

前提是你 提交于 2019-12-03 12:39:54
When setting your device to a Right-To-Left language, iOS reverses the order of items. For example in a UITableViewCell set with Auto-Layout: I have an avatar image on the left and some text aligned right from it that fills up the rest of the cell. In Arabic my avatar is on the right and my label is on the left. Is there a way to prevent iOS from doing this on certain views, or is there a general setting defining whether or not it can be reversed? For Xcode6 and iOS8 you can uncheck Respect language direction for the horizontal constrains like below: You can set the 'direction' property of a

calling initWithNibName doesn't initialize items in the nib, it has 0x0

谁都会走 提交于 2019-12-03 12:34:49
问题 When I call: self.viewController = [[DidItViewController alloc] initWithNibName:@"DidItViewController" bundle:nil]; and then I check self.viewController.navController right after this line is executed in the debugger, I find that it's empty (0x0). On DidItViewController I have my navController defined as: IBOutlet NavigationController *navController; and in my nib file I have the NavigationController bound to this navController property on the File Owner (a DidItViewController). Why doesn't

Good reasons why to not use XIB files?

天大地大妈咪最大 提交于 2019-12-03 11:46:53
问题 Are there any good reasons why I should not use XIB / NIB files with an highly customized UI and extensive animations and super low memory footprint needs? As a beginner I started with XIB. Then I figured out I couldn't do just about everything in them. It started to get really hard to customize things the way I wanted them to be. So at the end, I threw all my XIBs away and did it all programmatically. So when someone asks me if XIB is good, I generally say: Yeah, if you want to make crappy

Group views in Interface Builder

自闭症网瘾萝莉.ら 提交于 2019-12-03 11:31:23
问题 Is there any way to move a group of views within another without grouping all in the center ? Edit: Here some images with the process. 1.- I have a view with separate subviews (labels, buttons, images...) 2.- I create a new view (that will contain all the subviews) 3.- Select all the subviews and put them in the new super view. 4.- When the subviews are in the new "super"view, all of them are centered and I need to relocate all. 回答1: I found a very nifty solution that you are not gonna

iOS9 - UITableViewCellContentView is covering up Controls inside Cell

本小妞迷上赌 提交于 2019-12-03 09:51:12
问题 I have made a custom UITableViewCell called "SwitchCell" that has a switch. In iOS9 Only, using Xcode 7 beta, the Content view in the cell is on top of the switch. (See screenshot of View Hierarchy. You can clearly see that the content view of the cell is on top of the other views. ): So all the touches to the UISwitch are intercepted, and the IBAction does not fire. In iOS8, this is not a problem. See screenshot for iOS 8.4 simulator. You can see that there is no content view on top of the

UIButton, created by Interface Builder, is crashing

别说谁变了你拦得住时间么 提交于 2019-12-03 08:42:58
I have narrowed down an ugly bug, but since it seems like something internal to the nib/Interface Builder, I'm at a loss of what to do next. I've got a UIView created in IB which functions as a custom dialog box. It shows a message and two buttons. (Proceed or Cancel.) Both buttons have a Background image set in Interface Builder. Something is wrong with the way the background image for the cancel button is being handled. With NSZombieEnabled, I've been running the program. Most often, the method below logs this: -[ModalDialog showInView:title:message:cancelText:proceedText:]