uikit

UIScrollview contentOffset changes when removed from window

。_饼干妹妹 提交于 2019-12-23 16:35:48
问题 I have a weird bug concerning an UIScrollView. This view works fine, until the moment I remove it from the window (indirectly, it's a subview to a removed view). I then perform some unrelated animation ; and when I put the views where they were, the scrollView's contentOffset has changed. I put a breakpoint in setContentOffset: function, and got the following stack : #0 -[TestScrollView setContentOffset:] (self=0x915fbd0, _cmd=0x7fb34cd, contentOffset={x = 80, y = -0}) at /Users/..

iOS - Adding Target/Action for UITextField Inside Custom UITableViewCell

早过忘川 提交于 2019-12-23 15:46:17
问题 I have UITableView which uses a custom UITableViewCell containing a UITextField . I want to call a method ( myMethod ) when it is clicked ( UIControlEventTouchDown ) and attempted to wire this up inside the UITableView delegate method cellForRowAtIndexPath by doing the following: [tf addTarget:self action:@selector(myMethod) forControlEvents:UIControlEventTouchDown]; When the UITextField is clicked, nothing happens. I attempted to do the exact same thing for another UITextField outside of the

Gradient tint color in segmented control

别说谁变了你拦得住时间么 提交于 2019-12-23 15:43:59
问题 I get gradient image with this method func gradient(size:CGSize,color:[UIColor]) -> UIImage?{ //turn color into cgcolor let colors = color.map{$0.cgColor} //begin graphics context UIGraphicsBeginImageContextWithOptions(size, true, 0.0) guard let context = UIGraphicsGetCurrentContext() else { return nil } // From now on, the context gets ended if any return happens defer {UIGraphicsEndImageContext()} //create core graphics context let locations:[CGFloat] = [0.0,1.0] guard let gredient =

How to jump to a particular page with UIPageViewController?

别说谁变了你拦得住时间么 提交于 2019-12-23 13:07:00
问题 I'm using Xcode 8's default Page-based application, and I'm stuck trying to jump to a particular page (as opposed to swiping left and right to turn). I have found similar questions on StackOverflow, but the answers mostly suggested using this method: setViewControllers:direction:animated:completion I don't need to change the number of pages to be displayed, so can I avoid using setViewControllers ? After reading through Xcode's page-based application template, I think this function may work:

Can UIDatePicker's minimumDate and maximumDate include time?

不打扰是莪最后的温柔 提交于 2019-12-23 11:45:56
问题 Need a UIDatePicker with specific maximum and minimum dates and times . Currently NSDatePicker.minimumDate and .maximumDate appear to only consider the date. What's the proper way to handle this? 回答1: NSDates contain both the date and the time. From the docs: NSDate objects represent a single point in time. The example below has the current date and time as the minimum value and the time an hour from now as the maximum value (to test it just drop it into the viewDidLoad of any

UINavigationBar right button not showing up

安稳与你 提交于 2019-12-23 10:17:15
问题 I am using the following function via a notification to load a right button on my UINavigationBar, and even though I can trace out the button and verify it is allocated, it does not show up...any ideas? EDIT 4/6/2011, 2:42PM So, something interesting...the width always reports as 0.0... - (void)showRightBarButton:(id)sender { NSLog(@"Showing button"); UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(showPI:)];

How to add UIKit to an Xcode project?

妖精的绣舞 提交于 2019-12-23 10:15:37
问题 I've imported another programmer's project into Xcode and get the error "UIKit/UIKit.h file not found." I tried right clicking the Frameworks folder but didn't see a way to add it. How can I add the UIKit to this project? 回答1: Navigate to the target and go to Build Phases and add UIKit to Link Binary With Libraries . From the Comments to this post: MonkeyBusiness: Sorry to waste your time. I had set the project up as MacOS rather than iOS. I'm new to Apple and iOS as you can see. 回答2: Check

iPhone UIScrollView / setContentOffset weirdness

只谈情不闲聊 提交于 2019-12-23 09:59:07
问题 I have a weird issue with setContentOffset which I don't seem to be able to solve: I'm trying to build an "endless" scroll view, so I'd like to reset the content offset at a certain position. With the code below setContentOffset will be called at x=160px. If I drag the scroll view my log looks like this: offset: 158 offset: 159 offset: 160 offset: 80 offset: 160 What happens is that my setContentOffset (to 80) is performed, when I keep on dragging UIScrollView seem to have forgotten about it

UIViewControllerAnimatedTransitioning with Safe Area Insets on iPhone X

前提是你 提交于 2019-12-23 09:11:17
问题 When animateTransition is called on the transitioning delegate the Safe Area Insets have yet to be set on the 'to view controller'. I've tried forcing a layout by calling: toViewController.view.setNeedsLayout() and toViewController.view.layoutIfNeeded() without success. Can anyone suggest a means of either forcing the Safe Area Insets to be set early or determining how I should know the insets in time for the transition to work as it ought. The effect is that I have a UICollectionViewCell

UIDocumentInteractionController - Change background Color and prevent status bar popup

旧时模样 提交于 2019-12-23 07:39:01
问题 When I use the UIDocumentInteractionController it's background color is always white in the beginning and when I tap it, it gets black (and back when tapped again). Can I somehow invert this or even set a custom background color for both modes? Another interesting bug is that once I touch the screen the status bar (which I have disabled) pops back up. So white screen with document --> tap screen --> black background with status bar --> tap white screen withs status bar. Once I dismiss that