cocoa-touch

Sorting an nsarray of strings not string based

依然范特西╮ 提交于 2020-01-01 11:35:09
问题 So i have an array that i retrieve from a web service in no particular order example: 0 => x large, 1 => large, 2 => XX large, 3 => small, 4 => medium, 5 => x small I need to sort them: firstly based on specific - which could be reverse alphabetic: small medium large Secondly i need to sort them based on their 'x' counter parts: x small small medium large x large xx large I know i can do this with brute force string matching but i would really like a suggestion on how to do this tidily,

How to obtain an unformatted string representation of an NSDecimal or NSDecimalNumber?

£可爱£侵袭症+ 提交于 2020-01-01 10:40:31
问题 I have an NSDecimal and need this as technical string, i.e. with no formatting in any way. Floating point should be a "." if there is any, and minus sign should just be a "-" if there is any. besides that, there should be no formatting going on like grouping or chinese numbers. I was looking for 2 hours through the SDK but it seems there is nothing simple to accomplish this. Are there solutions for this? 回答1: For NSDecimal, you can use NSDecimalString with a specified locale: NSLocale

Preventing MFMailComposeViewController from scaling animated GIFs

北城余情 提交于 2020-01-01 10:12:22
问题 I'm attaching an animated GIF to an email to be sent with MFMailComposeViewController. If the GIF is of sufficient size the MFMailComposeViewController will ask the user whether they want to resize it to a smaller size. Unfortunately, the animation will not be preserved in the resized image. How do I either forbid MFMailComposeViewController to resize the image or make it preserve the animation? 回答1: There’s no built-in API to do this, but one option is to compress the animated GIF into a ZIP

Preventing MFMailComposeViewController from scaling animated GIFs

匆匆过客 提交于 2020-01-01 10:11:56
问题 I'm attaching an animated GIF to an email to be sent with MFMailComposeViewController. If the GIF is of sufficient size the MFMailComposeViewController will ask the user whether they want to resize it to a smaller size. Unfortunately, the animation will not be preserved in the resized image. How do I either forbid MFMailComposeViewController to resize the image or make it preserve the animation? 回答1: There’s no built-in API to do this, but one option is to compress the animated GIF into a ZIP

blocking user interaction with underlying views

烈酒焚心 提交于 2020-01-01 09:34:26
问题 In my app, i have an overlay view, which is displayed when some processing and networking is happening. It is just a semitransparent view (subclass of UIView) with a loading indicator on it, filling the whole screen. I want to prevent any of the underlying views to recieve user-interaction (e.g. a underlying table view should not be scrolled, a button not be pressed). What is the best way i can do this from within the overlay view? 回答1: Just set the userInteractionEnabled property for the

UIView Subclass initWithFrame not being called?

老子叫甜甜 提交于 2020-01-01 09:05:22
问题 I have a custom UIView subclass. In IB, I have specified a "placeholder" UIView and set the class to my class name. My override of drawRect method is working, and the background is coloring properly, but the initWithFrame is not firing. Why? - (id)initWithFrame:(CGRect)frame { NSLog(@"initWithFrame"); if ((self = [super initWithFrame:frame])) { noteTextFont = [[UIFont boldSystemFontOfSize:12] retain]; } return self; } - (void)drawRect:(CGRect)rect { [super drawRect:rect]; CGContextRef context

Xcode expired certificate problem

做~自己de王妃 提交于 2020-01-01 09:04:08
问题 please look at the following screenshot As you see there are two certificates. All are mine, with maching user's ID and common name. Whenever I build the application and launch it in Xcode for device I receive the fatal, that this certificate is duplicated. So I delete the expired one and launch the application again - it's being installed and debugged on device without any problems. But when I launch other project or reboot that expired certificate is shown in the keychain again and again

Issues using NSIndexPath as key in NSMutableDictionary?

点点圈 提交于 2020-01-01 08:53:34
问题 Is there any particular reason why attempting to store and retrieve a value in an NSMutableDictionary using an NSIndexPath as a key might fail? I originally attempted to do this in order to store an NSMutableDictionary of UITableViewCell heights ( self.cellHeights ) for a UITableView . Each time you tapped a UITableViewCell , that cell would either expand or contract between two different heights based on the value stored in the NSMutableDictionary for that particular indexPath : - (CGFloat

How can I create a custom popup window for iPhone?

流过昼夜 提交于 2020-01-01 08:53:25
问题 I want to create a custom popup window for iPhone which should look like this: What is the most correct way to implement this for iPhone and iPod devices? 回答1: The best way to do this is using a UIActionSheet. The code is here: UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"Share" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Facebook",@"Twitter", nil]; [actionSheet showInView:self.view]; A UIActionSheet comes from the bottom to

Issues using NSIndexPath as key in NSMutableDictionary?

此生再无相见时 提交于 2020-01-01 08:53:09
问题 Is there any particular reason why attempting to store and retrieve a value in an NSMutableDictionary using an NSIndexPath as a key might fail? I originally attempted to do this in order to store an NSMutableDictionary of UITableViewCell heights ( self.cellHeights ) for a UITableView . Each time you tapped a UITableViewCell , that cell would either expand or contract between two different heights based on the value stored in the NSMutableDictionary for that particular indexPath : - (CGFloat