cocoa-touch

performSelector:withObject:afterDelay: not working from scrollViewDidZoom

不羁的心 提交于 2020-04-29 08:20:34
问题 I feel like I should know this but I've been stumped for hours now and I've run out of ideas. The theory is simple, the user manipulates the zoom and positioning in a scrollview using a pinch. If they hold that pinch for a short period of time then the scrollview records the zoom level and content offsets. So I thought I'd start a performSelector:withObject:withDelay on the scrollViewDidZoom delegate method. If it expires then I record the settings. I delete the scheduled call every time

Unable to detect http links using Regex

回眸只為那壹抹淺笑 提交于 2020-04-18 08:41:27
问题 I am using TTTAttributedLabel to detect hyperlinks in my text so that I can make them clickable. My code does not work, and links aren't clickable. In fact, everything is clickable. I only want URL's to be clickable. here is the regex: static NSRegularExpression *websiteRegularExpression; static inline NSRegularExpression * WebsiteRegularExpression() { if (!websiteRegularExpression) { websiteRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"\b(https?|ftp|file)://[-A-Z0-9+&@#/

UITextview show vertical scrollbar all the time

被刻印的时光 ゝ 提交于 2020-04-10 06:03:55
问题 I am trying to show vertical scrollbar on uitextview at the beginning with the code but it isn't doing so. UITextView *txtView=[[UITextView alloc]initWithFrame:CGRectMake(10, 80,self.view.frame.size.width-20,self.view.frame.size.height/2)]; [txtView setEditable:NO]; [txtView setSelectable:NO]; [txtView setText:self.secret]; [txtView setBackgroundColor:[UIColor clearColor]]; [txtView setTextColor:[UIColor whiteColor ]]; [txtView setFont:font]; txtView.showsVerticalScrollIndicator=YES; [txtView

UITextview show vertical scrollbar all the time

╄→гoц情女王★ 提交于 2020-04-10 06:02:08
问题 I am trying to show vertical scrollbar on uitextview at the beginning with the code but it isn't doing so. UITextView *txtView=[[UITextView alloc]initWithFrame:CGRectMake(10, 80,self.view.frame.size.width-20,self.view.frame.size.height/2)]; [txtView setEditable:NO]; [txtView setSelectable:NO]; [txtView setText:self.secret]; [txtView setBackgroundColor:[UIColor clearColor]]; [txtView setTextColor:[UIColor whiteColor ]]; [txtView setFont:font]; txtView.showsVerticalScrollIndicator=YES; [txtView

How to apply structs to modeling the data a view controller operates on

落花浮王杯 提交于 2020-03-25 19:20:24
问题 I'm trying to embrace Swift's value types more in my application design, but I'm having some beginner difficulties. I know those generally don't go over well in the StackOverflow format for being opinion-based, but I think there are best-practices here that are probably not particularly subjective. I understand all the theoretical benefits of structs, about avoiding shared mutable state, the copying behaviour that makes it easy to implement "undo", etc., but I have a hard time using it in

How do I adjust my content views so that they are not obscured by the keyboard?

元气小坏坏 提交于 2020-03-25 17:36:41
问题 When the keyboard slides up in my iPhone application, it obscures a large portion of the screen. How do I adjust my views so that they are not hidden under the keyboard? 回答1: You'll find nice code for that here. Just go to the section called : Moving Content That Is Located Under the Keyboard You can use and adapt what the documentation said to move your view when the keyboard is visible. Hope this helps ! 回答2: I usually move up my whole UIView so you can see both keyboard and textfield 来源:

Subclasses of MKAnnotationView

喜夏-厌秋 提交于 2020-03-18 06:06:26
问题 I was wondering if anyone knows of any subclasses for the MKAnnotationView class. On apples documentation they say one example is the MKPinAnnotationView so I was wondering if there were other pre-created subclasses like the one used to track the devices current location. If anyone has tips for creating my own subclass of the MKAnnotationView class that be great as well. Thanks, bubster 回答1: I don't know of any other templates, but that does not mean that they don't exist. :) Anyway, here's

Hide, show annotation on MkMapView

吃可爱长大的小学妹 提交于 2020-03-17 07:29:47
问题 How to hide annotation when zooming out the map view. I have a big number of annotation i have to hide them because if the region displayed on the map is too big you can see only the annotations. 回答1: To do this, you have to check the size of your region, and depending of it you set the views hidden or not. I tested the code bellow but, you will probably need some adjustments. - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated { NSArray *annotations = [_mapView

iPhone - how to select from a collection of UILabels?

爱⌒轻易说出口 提交于 2020-03-16 11:28:45
问题 I have a few UILabels, any one of which will update according to the index of an NSArray index they represent. I thought of selecting them by their tag self.displayLabel.tag = myArray[index]; but that changes the tag value to whatever my array is holding at the moment Using a dictionary for whatever tricks it offers instead of an NSArray doesn't help because i still have to select the correct matching label. This is the effect i want to achieve. self.|mySelectedLabel|.text = myArray[index];

iPhone - how to select from a collection of UILabels?

蓝咒 提交于 2020-03-16 11:28:42
问题 I have a few UILabels, any one of which will update according to the index of an NSArray index they represent. I thought of selecting them by their tag self.displayLabel.tag = myArray[index]; but that changes the tag value to whatever my array is holding at the moment Using a dictionary for whatever tricks it offers instead of an NSArray doesn't help because i still have to select the correct matching label. This is the effect i want to achieve. self.|mySelectedLabel|.text = myArray[index];