xib

Cell from Xib with Swift 3

∥☆過路亽.° 提交于 2019-12-09 04:20:30
问题 I already read and saw some videos about this subject but i can't get this to work. Im trying to a cell from a xib instead of the storyboard. This is my ViewController (where i have the Table View). import UIKit class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning

UITableViewCell throwing exception

廉价感情. 提交于 2019-12-09 02:49:44
问题 I am updating a project to iOS 8 and am running into this issue with one of my UITableViewCell implementations. Currently on Simulator and not a device and it is set to "iPhone 6". *** Assertion failure in -[UITableViewCell _setHostsLayoutEngine:], /SourceCache/UIKit_Sim/UIKit-3318/NSLayoutConstraint_UIKitAdditions.m:2754 2014-09-15 10:43:52.890 BasketballStatTracker[10662:304085] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Must translate

How to inherit a custom view which has a .xib file

六月ゝ 毕业季﹏ 提交于 2019-12-08 17:47:28
There is a custom view, that consist of class and xib file. I use it as [[NSBundle mainBundle] loadNibNamed:@"myViewNib" owner:self options:nil]; Question is how to inherit this custom view. I inherit the myViewClass, but then I can't use the code above to create a instance.I think I'm in the wrong way. One option is not to create MYBaseView itself in the .xib file, but it's subview. This way you will be able to inherit MYBaseView easily. This is the code should work correctly if you create your view object programmatically or in the Interface Builder: - (id)initWithCoder:(NSCoder *)aDecoder {

Changing size of UIButton while using Autolayout?

时光总嘲笑我的痴心妄想 提交于 2019-12-08 12:21:10
问题 I'm pretty new to ios. I'm working on a project which is going to frequently use a certain UIView class throughout the application. This class is simply an image that does some transparency stuff with the background color. This works fine so far. This class sometimes exists as a lone UIView, and sometimes as a button subview. When I add this UIView to a UIButton as a subview, the full contents of the UIView are displayed at full size, but the clickable area of the button remains the size

Swift - Add Custom Xib View As Subview Programmatically

北慕城南 提交于 2019-12-08 10:28:37
问题 Ive made a custom xib that I've used in my storyboard before and i want simply create an instance of the custom view adjust size and then add it as a subview to a uiscrollview. Ive tried using this block of code in the viewdidload func of my view controller let cardView = CardView(coder: NSCoder()) cardView!.frame.size.width = 100 cardView!.frame.size.height = 100 scrollView.addSubview(cardView!) but I'm getting this error Terminating app due to uncaught exception 'NSInvalidArgumentException'

iOS - How to initialize custom UIView with specific Frame from NIB

限于喜欢 提交于 2019-12-08 08:43:23
问题 I am wondering what is the cleanest way to initialize a custom UIView with a specific frame. The UIView is designed from a XIB file. Here is my implementation : class CustomView : UIView { @IBOutlet var outletLabel: UILabel! public required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) setupView() } public override init(frame: CGRect) { super.init(frame: frame) setupView() } private func setupView() { // Set text for labels } } Here is how I want to initialize it in my

Changing view from xib to storyboard

China☆狼群 提交于 2019-12-08 08:21:12
问题 I have a Storyboard project witch i need to have an xib file loading on startup, to show a login screen. Its based on a UIWindow and a view controller so i dont get it to work in storyboard. Anyways is there anyway that after this xib is loaded at start to push the view in to story board? the storyboard is Tabbarbased if i does any difference. Thanks. 回答1: I think this would solve your problem : How can I load storyboard programmatically from class? It is definitely possible. 来源: https:/

How to inherit a custom view which has a .xib file

試著忘記壹切 提交于 2019-12-08 08:06:16
问题 There is a custom view, that consist of class and xib file. I use it as [[NSBundle mainBundle] loadNibNamed:@"myViewNib" owner:self options:nil]; Question is how to inherit this custom view. I inherit the myViewClass, but then I can't use the code above to create a instance.I think I'm in the wrong way. 回答1: One option is not to create MYBaseView itself in the .xib file, but it's subview. This way you will be able to inherit MYBaseView easily. This is the code should work correctly if you

No Visible View in Custom Table View Cell

拈花ヽ惹草 提交于 2019-12-08 05:26:16
问题 I am doing an exercise about tableView and tableViewCell . And I am having some problems with custom view cells. I have created my own custom tableViewCell with .xib file called as newCellView.xib . I have required .h and .m files and I choose super class as UITableViewCell . In my view controller called as TableViewController I was creating a table with default cells like this. - (UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {

Is this a correct way of creating a universal iOS app? Xcode 4 - Seems to work?

冷暖自知 提交于 2019-12-08 05:18:45
问题 Here is how I made a universal app from an existing iPhone project by creating ~ipad.xib(s) using duplicate and then adding them back to a backup of the project, and checking universal. I used xcode 4.02 with a base sdk of 4.3.3 with a deployment target of 3.1.2. Back up your whole project somewhere. Right click on iPhone target and choose duplicate. Choose duplicate for iPad rather than just duplicate. This makes a new folder called Resources-iPad with a subfolder called classes under that,