cocoa-touch

How do I get a list of countries in Swift ios?

余生颓废 提交于 2020-01-01 03:59:05
问题 I've already seen two similar questions to mine, but the answers for those questions do not work for me. I have an old project with a list of countries manually typed out inside a set of square brackets. I can easily use this in my pickerView but I'm wondering if there is a more efficient way to do this? I will be using the list of countries in a UIPickerView. 回答1: You can get a list of countries using the NSLocale class's isoCountryCodes which returns an array of [String] . From there, you

Display UIMenuController in editingDidBegin of a UITextField

非 Y 不嫁゛ 提交于 2020-01-01 03:47:06
问题 I simply want to display the UIMenuController right after a textfield has become active. What i'm doing right now is: - (IBAction)textFieldeditingDidBegin:(UITextField *)sender { // textfield menu item UIMenuController *menu = [UIMenuController sharedMenuController]; [menu setTargetRect:sender.frame inView:self.view]; [menu setMenuVisible:YES animated:YES]; } The method gets called but it just will not display the menu... If i do a touch+hold gesture on the textfield it comes up regularly. I

Group by weekdays with Core Data

百般思念 提交于 2020-01-01 03:43:06
问题 In my Core Data Model i've got an entity that has a date attribute and as the title suggests, i'd like to group this entity by (week)days. The problem is, the dates are stored more or less as timestamps and i don't know how to create a predicate that is capable of grouping/filtering my entities approprioately. I've figured out that i will probably have to do a fetch for each day, so created following method. The code were i need help with is right in the middle of it. -

UIFont fontWithName: limited to loading 2 variations per family

纵饮孤独 提交于 2020-01-01 03:33:14
问题 This question is extremely similar to UILabel with custom font displays *wrong* custom font, except I need to use three fonts from this family simultaneously. I am using Myriad Pro, just like that question, but I need to use Bold, Semibold, and Regular. Currently, when I try to use Bold via a macro defined as: #define MYRIAD_BOLD(x) [UIFont fontWithName:@"MyriadPro-Bold" size:(x)] ..it gives me Semibold. If I remove Semibold from the plist entries for "Fonts provided by application" (as is

String manipulation without memory leaks?

大憨熊 提交于 2020-01-01 03:26:07
问题 I'd like to do a series of string substitutions to removed xml-escaped chars such as '&' . 1) Is there an existing UIKit function that can do this? 2) If not, what's the best way to do it without leaking memory? Here's the idea: -(NSString*) unescape:(NSString*)string { string = [string stringByReplacingOccurrencesOfString:@"'" withString:@"'"]; string = [string stringByReplacingOccurrencesOfString:@"&" withString:@"&"]; string = [string stringByReplacingOccurrencesOfString:@"""

Signature in UIView

折月煮酒 提交于 2020-01-01 03:22:45
问题 I am looking for a class that will allow the user to draw?(the main purpose is to get their signature). I checked Cocoa Controls but couldn't find such a class. Just want to now if there's any before I start writing it myself. Thanks 回答1: Look at this tutorial: http://www.ifans.com/forums/showthread.php?t=132024 To get a JPG or PNG file, you can use the functions UIImageJPEGRepresentation or UIImagePNGRepresentation . They take a UIImage as input. And to get a UIImage from a UIView , you can

NSDate dateByAddingTimeInterval subtracting days incorrectly changes time

社会主义新天地 提交于 2020-01-01 03:21:08
问题 Am I missing something about how NSDate dateByAddingTimeInterval works with days? Here is my code for subtracting 33 days from a specific date (AIDate). AIDate has a time value of 00:00 PST. activityOne.ActivityDateTime = [AIDate dateByAddingTimeInterval:-33*24*60*60]; If the AIDate equals 4-9-2013 00:00 PST, the above code will subtract 33 days and 1 hour which works out to 3-6-2013 23:00 PST. 回答1: 24*60*60 means 24 hours, and not 1 day. There is a huge difference between those two when your

Adjust UIPopoverController position after resize

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-01 03:21:08
问题 I have a UIPopoverController containing a UITableView . The popover is resized in its view controller's -viewDidAppear function to fit the contents of the table. While the popover resizes properly, its arrow is usually no longer pointing at the original CGRect . Is there a way to force the popover to reposition itself after a resize so that its arrow is pointing at its intended target? EDIT: I can't set the size of the popover in -viewDidLoad since the table view does not load its data until

What classes do I use to make an iPhone act as a server?

十年热恋 提交于 2020-01-01 03:17:27
问题 I'm looking for an easy way for users to download content from an iPhone to their computer. I've seen other apps that actually turn the iPhone into a server and give the user an IP address to navigate to on their computer. I've glanced at some Apple samples, but nothing looked too much like what I was going for. So what's the easiest way to make a server that listens on TCP port 80 (even better, an HTTP server) and sends responses? Hopefully using Objective C classes, but I can make a wrapper

Is the iOS Local Notification Limit Per Day?

社会主义新天地 提交于 2020-01-01 03:15:12
问题 I'm working on an app where I need to send a good amount of notifications to the user daily. Around 5-40 depending on the user. I'm using local notifications to send it, but I know there is a 64 notification limit. Does this mean 64 notifications per day, or in total? 回答1: It means simultaneously scheduled for future delivery. You can send as many as you want per day, provided they don't overlap. If you add more than 64 requests (under UserNotifications ) or scheduled (under UIApplication /