xib

When are XIB outlet properties set?

↘锁芯ラ 提交于 2019-12-23 13:58:37
问题 I'm trying to implement inheritance with xib files. Yes, a little strange, but let me tell you why. I have a class, SLBaseViewController that many of my view controllers inherit from. When I want a child view controller I create it in the usual way: SLHomeViewController *controller = [[SLHomeViewController alloc] initWithNibName:@"SLHomeViewController" bundle:nil]; This works fine. SLHomeViewController is an SLBaseViewController (which is a UIViewController). I'm doing this because I have

How to load a XIB with a top-level ViewController?

拈花ヽ惹草 提交于 2019-12-23 08:47:34
问题 I've got a nib with a view controller root element like this: so I can position elements relative to the top and bottom layout guides using auto-layout. When I first tried to load this nib using SearchViewControllerPro* searchViewController = [[SearchViewControllerPro alloc]initWithNibName:@"SearchViewControllerPro" bundle:[NSBundle mainBundle]]; I got the following run-time exception: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController

How to load xib file with attached view controller?

醉酒当歌 提交于 2019-12-23 07:30:59
问题 I am using a xib file as a back view in coverflow component . and it is seeing nicely . The code for loading a xib file is : NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"TestMine" owner:nil options:nil]; backView = [array objectAtIndex:0]; Now I want to attach a view controller with this xib without changing the current code . How can I do so ? I am getting the error : Exception :*** -[UIViewController superview]: unrecognized selector sent to instance 0x5891120 Tell me if more

How to create a custom UIView?

跟風遠走 提交于 2019-12-23 04:26:15
问题 I've created a UIView subclass and corresponding xib file where I've laid out some UILabels and UIImageViews. I want to then put multiple copies of this custom UIView into a UIViewController. When I do that they appear blank in interface builder and don't appear when the app loads. What methods do I need to implement on the UIView subclass to make this work? 回答1: The easiest method by far is to create a nib with File's Owner set to NSObject, containing one view containing your layout element.

Xcode: Copy files from one Project to another in same workspace

爷,独闯天下 提交于 2019-12-23 02:34:54
问题 I am currently working on legacy code for an iPhone application. Someone has implemented a feature in the iPhone and now I am trying to implement it into iPad. To start with I have decided to drag the files from the iPhone project into the iPad and get it working. Then I am going to find a solution where by both projects can share the same code. However I have copied the files from the iPhone project into the ipad project and have a problem with the xib. The outlets are still referencing the

There is a problem when i am getting index of subview

一笑奈何 提交于 2019-12-23 01:35:16
问题 There is a problem when i am getting index of subview. int index = [[YourUIView subviews] indexOfObject:YourUIButton]; Some UITextField are created with xib file. When i printed its value i get unreal index. @property (nonatomic, retain) IBOutlet UITextField *distanceTextField; for example: index is equal to 2147483647 But when i add object programmatically i get real index. index is equal to 12. Why ? 回答1: Each time you perform a search for some index (or range) with framework methods check

Get the type name of derived type in a static method of base class or extension Swift

谁都会走 提交于 2019-12-22 18:39:09
问题 TL:DR Paste this into Swift playground: import UIKit public protocol NibLoadable { static var nibName: String { get } } extension NibLoadable where Self: UIView { public static var nibName: String { return String(describing: self) } func printName(){ print(Self.nibName) } } public class Shoes: UIView, NibLoadable { required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) printName() } override init(frame: CGRect) { super.init(frame: frame) printName() } } public class Cake: Shoes

Xcode 7 - Cannot open document (storyboard file)

我的梦境 提交于 2019-12-22 14:38:42
问题 I recently updated to Xcode 7 and as usual something has to go wrong. Its really a shame because I was looking forward to the new features in Xcode 7. I am faced with a an error which I cannot seem to fix. Every time I try and build the project I get the following error: I thought there was something wrong with my project, so I made a new Single View application and I still get the same error. I have tried the following things but none of them has worked for me: Restart Xcode (Didn't work).

How to add app delegate back to mainwindow.xib

对着背影说爱祢 提交于 2019-12-22 13:07:09
问题 short answer: drag a Object from Object library and set its class to delegate. Details see the answer below. I accidentally removed app delegate from mainwindow.xib. I looked into everywhere but still cannot find a way to add it back. I tried to find it online and still got no result. Can anyone help me to fix it? Thank you. My project Other's project Main.m #import <UIKit/UIKit.h> int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, nil); } } 回答1:

iPhone localization for xib files

谁都会走 提交于 2019-12-22 05:04:54
问题 I am just getting familiar with the localization of xib files and was wondering if there's a way of localizing the strings within the xib by refering to the plists directly... Appreciate some thoughts.. 回答1: If you don't want to localize the .xib files directly, you can extract the text they contain into .strings files and, once the .strings files are translated, inject them back into your .xib file to produce localized versions. These extract/inject operations are done using the ibtool