xcode6

Using auto layout with static background image

风格不统一 提交于 2019-12-12 06:19:44
问题 I am new to auto-layout and struggling with the layout of a view. I have a UIImage pinned to the superview (0,0,0,0), it is set to aspect to fit. I am struggling to add labels and buttons that remain in position relative to the image as the device screen size changes What would be best way to set these labels/buttons to change with screen size and background image? I am trying make each objects height relative to its direct parent and then leading edge of superview. Any input appreciated 来源:

Can't make UiTableView work

拜拜、爱过 提交于 2019-12-12 04:55:45
问题 I am working on a project on XCode 6 and Swift. I need to add a UITableView to a UIViewController, and then fill the table with content. So, on my default UIViewController, I added a UITableView and a UITableViewCell (using the storyboard). Next, I set the UIViewController as the dataSource and delegate for the table. Finally, I added this code to my view controller.swift: import UIKit class ViewController: UITableViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet var

Recovering a lost connection using sockets

梦想的初衷 提交于 2019-12-12 04:54:19
问题 I'm trying to dig deeper by using this example of an iPhone Chart Server and all is working as expected. What I wanted to learn next is how to recover when the connection to the server is lost (for whatever reason) while the app is running. First issue is that the app tries to open the input & output streams concurrently thus if I implement an alert, I get it two times. I managed to resolve this by closing the streams if there is an error. The second is that if I'm another view controller and

Swift array cannot be downcast to array of derived [duplicate]

微笑、不失礼 提交于 2019-12-12 04:46:08
问题 This question already has answers here : How come I can cast to NSManagedObject but not to my entity's type? (8 answers) Closed 5 years ago . I am using Core Data in Swift and am having trouble storing the array returned from a fetch request. I have two entities in my data model: Task and Homework. Homework's parent entity is Task. I auto generated the classes for the two entities: Task.swift import Foundation import CoreData class Task: NSManagedObject { @NSManaged var name: String

take image from UITextView

依然范特西╮ 提交于 2019-12-12 04:36:13
问题 I have a UITextView containing text only and I want to take a snapshot from it. I created it programmatically. UITextView *textView = [[UITextView alloc] init]; If the background color of the UITextView is black and the text color is white, I want to parse each pixel to know if I'm on the white or black pixel. How to do the snapshot to get an image from the UITextView (only if possible) ? 回答1: implement this method as UIView category, and you would can draw any UIView as image: - (UIImage*

How to fit tableview to superview below navigation bar via storyboard autolayout

旧巷老猫 提交于 2019-12-12 03:17:09
问题 I want to create a scroll disabled tableview which will fill the view below navigation bar. Finally I've managed to do it but it's not the right way because I'm giving minus 64 margin (status bar + navigation bar) to tableview. I'm assigning my constraints from storyboard. I've tried lots of other constraints with the table view like giving zero constraints from 4 sides or equal width + equal height + center horizontal + center vertical none of them worked. What is the right way to solve this

Accessing UIViewcontroller.traitCollection compiles but crashes my app

自闭症网瘾萝莉.ら 提交于 2019-12-12 02:57:14
问题 My storyboard is build in xcode6 and is using the new constraint based layouts. My app runs in two configurations, wRegular hRegular and wCompact hAny. Any time I try to access the traitCollection in code I get the following error: [MYUIControllerName traitCollection]: unrecognized selector sent to instance. I have also tried implementing the following function, but it never gets called. -(void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id

Strange behavior on scroll UITableView

久未见 提交于 2019-12-12 02:57:02
问题 I have a single view with nested scroll and table view with this hierarchical tree: (The table is loaded with some Huckleberry Finn rows taken from this example.) On viewWillAppear I programmatically scroll the Table View at the last row doing -(void)viewWillAppear:(BOOL)animated { [self.tableView reloadData]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[self.tableView numberOfRowsInSection:0]-1 inSection:0]; [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition

'SessionDelegate' does not have a member named 'xxx'

家住魔仙堡 提交于 2019-12-12 02:13:21
问题 I previously asked a question on how to create a protocol with optional methods. The response was, pretty much, use Objective-c. See it here. I did, and everything worked fine, because I was using var delegate: SessionDelegate?; That is, "delegate" is an optional SessionDelegate. In order to call methods from that delegate I could simply write: self.delegate?.willOpenSession?(self); Which was fine. But then I though, why make the delegate optional? So I changed it: var delegate:

Image sizes required to support all iPhone devices

馋奶兔 提交于 2019-12-12 02:01:14
问题 What all splash screen images do we required to create an iOS application? I want to give support all the devices which supports iOS8. Trying to find out working of Images.xcassates and how to add splash images. I want to support iPhone 4, iPhone 5/5s/5c, iPhone 6/6+, iPad. What is the naming convention required to set LaunchImage? I just saw 1x, 2x, Retina 4 2x, and 3x in xcassates. But not getting what file names it required. Like for non retina and and retina we simply twice non retina