cocoa-touch

Swift custom UITableViewCell label is always nil

♀尐吖头ヾ 提交于 2020-01-31 06:17:05
问题 I've been stuck with this problem for days, so I'd be really happy if someone could help. I'm trying to create a dynamic UITableView, for which I created a custom UITableView subclass and I've created a custom UITableViewCell subclass as well, because I need several UILabels and a UIButton in each cell. The cell is created, but the problem is that the value of the labels is always nil, hence the cell isn't displayed properly. This is, how the storyboard looks like, and this is what I see

UIWebView under transparent UINavigationBar

落爺英雄遲暮 提交于 2020-01-31 05:43:59
问题 I have a UIWebView which I want to put under my translucent UINavigationBar. Normally when I put a UIScrollView under a translucent UINavigationBar, I set its contentOffset such that all content will be initially pushed after the bar so that it can be seen; thereafter, the user can scroll text and it will underlap the bar. The problem is that UIWebView appears not to be a proper subclass of UIScrollView; thus, I can't use setContentOffset. Does anyone have any tips or tricks on getting a

UIWebView under transparent UINavigationBar

南笙酒味 提交于 2020-01-31 05:42:04
问题 I have a UIWebView which I want to put under my translucent UINavigationBar. Normally when I put a UIScrollView under a translucent UINavigationBar, I set its contentOffset such that all content will be initially pushed after the bar so that it can be seen; thereafter, the user can scroll text and it will underlap the bar. The problem is that UIWebView appears not to be a proper subclass of UIScrollView; thus, I can't use setContentOffset. Does anyone have any tips or tricks on getting a

UI Issue with kal calendar for ipad?

回眸只為那壹抹淺笑 提交于 2020-01-30 14:56:12
问题 I have UI issue with Kal Calendar for iPad. On the iPad there is an empty space but on the iPhone it's fine. How can i get it to fit in the frame on the iPad? if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { [kal.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { [kal.view setFrame:CGRectMake(0, 0,768 ,1004)]; } I tried to use the code listed above but it did not work for me!

How can I add a boolean value to a NSDictionary?

霸气de小男生 提交于 2020-01-30 13:52:22
问题 Well, for integers I would use NSNumber . But YES and NO aren't objects, I guess. A.f.a.i.k. I can only add objects to an NSDictionary , right? I couldn't find any wrapper class for booleans. Is there any? 回答1: You use NSNumber. It has init... and number... methods that take booleans, just as it does integers and so on. From the NSNumber class reference: // Creates and returns an NSNumber object containing a // given value, treating it as a BOOL. + (NSNumber *)numberWithBool:(BOOL)value and:

How to access created Directory? - NSCocoaErrorDomain Code=257

我的梦境 提交于 2020-01-30 12:55:16
问题 I am trying to create a new directory and put files into it. However, I'm getting Error Domain=NSCocoaErrorDomain Code=257 "The file “Offline” couldn’t be opened because you don’t have permission to view it." I am able to create this new directory and the file exists. let offlinePath = fileDirectory.appendingPathComponent("Offline") try? fileManager.createDirectory(at: offlinePath, withIntermediateDirectories: true, attributes: nil) files.forEach { file in if let localUrl = file.localUrl { do

TouchMoved and wrong screen range? or Bug in iOS?

一个人想着一个人 提交于 2020-01-30 10:55:08
问题 I found interesting bug in iOS, but trying to belive that i'm wrong. You have to do 2 things: 1) Create single-view template for iOS 2) Write small function in ViewController.m : - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* touch = [touches anyObject]; CGPoint point = [touch locationInView:[touch view]]; NSLog(@"%@", NSStringFromCGPoint(point)); }// so u can detect points of your touch So if u try to move finger on display from screen's top to bottom (portrait

iOS 6 rotation not working

喜欢而已 提交于 2020-01-30 08:54:11
问题 I have overridden my UINavigationController to implement these methods: -(BOOL)shouldAutorotate { return [[self.viewControllers lastObject] shouldAutorotate]; } -(NSUInteger)supportedInterfaceOrientations { return [[self.viewControllers lastObject] supportedInterfaceOrientations]; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation]; } Now from my first view, I modally present this

Dynamically sizing text with kerning to occupy the full width of a UILabel

馋奶兔 提交于 2020-01-29 19:46:11
问题 I have a layout with a UILabel placed above a fixed width view, shown below as a grey rectangle. The text needs to match the width of the fixed grey view. I achieved this by setting the adjustsFontSizeToFitWidth property on the UILabel to YES , settings the font size to something really large, and setting the minimumScaleFactor to something suitable small. This worked fine until… I had to add kerning to said text. I added the kerning by applying @{NSKernAttributeName: @1.40} to an attributed

Finish editing UITextField on back button tap

半城伤御伤魂 提交于 2020-01-29 19:06:01
问题 I have 2 controllers inside NavigationController. First pushes the second one to the stack and user can interact with the text field there. Then (in one scenario) user will tap on back button to be taken to the previous screen. Assuming that loading of second one is 'heavy', so I will be keeping only one instance of it once it is needed. Expected: I would like to have keyboard hidden once back button is pressed. Actual: First responder keeps being restored when I go back to the second for the