cocoa-touch

UILongPressGestureRecognizer on MKAnnotationView not working for single touch

懵懂的女人 提交于 2020-01-02 10:23:15
问题 I've been trying to use a UILongPressGestureRecognizer in a MKAnnotationView subclass. Interestingly the gesture recognizer only triggers when using two ore fingers/touches. What prevents the gesture recognizer to get triggered with only one touch? Implementation UILongPressGestureRecognizer *pressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; pressRecognizer.minimumPressDuration = 0.25; pressRecognizer.numberOfTapsRequired = 0;

How can I disable UITableView's cells reloading when scrolling it?

时光总嘲笑我的痴心妄想 提交于 2020-01-02 09:09:50
问题 I've encountered with the problem when I don't need UITableView to reload its cells when I scroll it upwards and downwards. In simple words i created custom cell's which have content that user can expand by clicking on it. For example I have a UILabel with a lot of text in it which doesn't display fully but user can click on button and expand text and consequently a label. All this I implement via [tableview beginUpdates] and [tableview endUpdates] . But when I click button and expand text or

Tapping between UITextFields in iOS7

杀马特。学长 韩版系。学妹 提交于 2020-01-02 08:47:31
问题 When a UITextField is selected and has a keyboard shown, if I tap other parts of the view the keyboard disappears. If I tap another UITextField , the keyboard stays up, the first textfield is deselected, and nothing happens. Then I need to tap on the other UITextFIeld again for selection to happen and a keyboard to appear. Is there a way to make a second UITextField immediately accessible when a first UITextField is selected? 回答1: If you reload the tableview in textFieldDidEndEditing , you'll

Hide keyboard in applicationDidEnterBackground: - screenshot problem

筅森魡賤 提交于 2020-01-02 08:31:14
问题 When the home button gets pressed I want to hide the keyboard and restore my view to a sane state, so that when the app is started/foregrounded again, there is no textfield selected and the keyboard is hidden. My app delegate has this implementation of the method: - (void)applicationDidEnterBackground:(UIApplication *)application { [tabBarController.view endEditing:YES]; } The keyboard does indeed get removed, but what I don't get is this: Apple's docs say that a snapshot of the app is taken

CALayer vs. drawInRect: performance?

旧巷老猫 提交于 2020-01-02 07:54:29
问题 I'm trying to draw some shadows in a rect. The shadow image itself is about 1px * 26px. Here's two methods I've thought of for drawing the image in the view: //These methods are called in drawRect: /* Method 1 */ [self.upperShadow drawInRect:rectHigh]; //upperShadow is UIImage [self.lowerShadow drawInRect:rectLow]; /* Method 2 */ CALayer *shadowTop = [CALayer layer]; shadowTop.frame = rectHigh; shadowTop.contents = (__bridge id)topShadow; //topShadow is CGImage [self.layer addSublayer

how to add video on another video as overlay

让人想犯罪 __ 提交于 2020-01-02 07:41:26
问题 I am stuck on overlay video into another video, as I successfully add video on another video but not able to make scale same for both videos. taking reference from this. note: I have to add overlay video with transparency so below video visible. 来源: https://stackoverflow.com/questions/39825323/how-to-add-video-on-another-video-as-overlay

UIView not autoresizing subview

五迷三道 提交于 2020-01-02 07:36:30
问题 I have a UIView a that has autoresizing subviews enabled. It's size is: <UIView: 0x7650180; frame = (0 0; 320 394); clipsToBounds = YES; autoresize = LM+RM+H; layer = <CALayer: 0x7650230>> I have another UIView b which i added to the view a . View b has flexible width/height. When I add it in, I expect it's height to change to 394 , but it remains the same as the in the nib ( 420 ): <UIView: 0x764f720; frame = (0 0; 320 460); autoresize = LM+W+RM+TM+H+BM; layer = <CALayer: 0x764f320>> What am

IOS: problem with NSOrderedDescending and NSOrderedAscending

ぃ、小莉子 提交于 2020-01-02 07:36:30
问题 I want to compare dates and I use this code in one example date values for my date are: date1 = 6/06/2011 date2 = 8/06/2011 if dateSelected = 7/06/2011 it's all ok, but if dateSelected = 6/06/2011 or dateSelected = 8/06/2011 the code don't entry inside my "if", why??? if (([dateSelected compare:date1] == NSOrderedDescending) && ([dateSelected compare:date2]== NSOrderedAscending)) {} 回答1: NSDates represent a point in time since 1/1/2000 00:00 UTC. So all of those dates have time components.

Why doesn't UIView (or it's subclasses) adopt the NSCopying Protocol?

隐身守侯 提交于 2020-01-02 07:35:09
问题 Can a Cocoahead please explain why UIView and it's sub classes don't adopt the NSCopying Protocol? I can see, philosophically, why UITouch would not be copy compliant, as it's a very temporal object. By UIView, and it's subclasses, especially UIButton, seem like they should be able to be copied. Certainly Apple has good reasons for doing things the way they do. Do you know their reason? 回答1: It would seem the question they asked wasn't "Why not?" but "Why do it?" There's little point to doing

Why won't my UIActivityIndicatorView stop animating?

早过忘川 提交于 2020-01-02 07:06:32
问题 I am trying to manage the activity indicator from my App Delegate, that way any of my views can put the indicator up. So, I am adding it as a subview to 'window' and start/stop as follows: - (void)didStartActivity { if( activityIndicator == nil ) { activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; activityIndicator.hidesWhenStopped = YES; activityIndicator.center = window.center; activityIndicator.transform =