cocoa-touch

iOS – Weird exception

流过昼夜 提交于 2020-02-03 01:47:13
问题 I'm getting a strange exception in Xcode 4.2.1 (ARC-enabled project) that I can't track down to the root of the problem. This is what the exception looks like: 2012-03-18 22:19:32.855 Project[14225:707] +[UIPickerTableViewTitledCell isEqualToString:]: unrecognized selector sent to class 0x3f2bbec4 2012-03-18 22:19:32.859 Project[14225:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIPickerTableViewTitledCell isEqualToString:]: unrecognized selector

Crop Screen shot programmatically

纵然是瞬间 提交于 2020-02-03 01:45:11
问题 I want to take screen shot through programmatically and send with Email. I am able to do this but here full screenshot attached with email but I want to crop the screen shot for sending. How can I do this Please suggest me to do this. Here is my code for taking screen shot. UIGraphicsBeginImageContext(self.view.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 回答1: I used

How do I send the data I have in my sqlite database to the server with HTTP and JSON

二次信任 提交于 2020-02-02 15:59:38
问题 I'm storing id,lat,lng, and timestamp in sqlite and now need to send it in an JSON object to the server. Here's where I'm inserting the data. NSString *insertStatement = [NSString stringWithFormat:@"INSERT INTO location (latitude, longitude, timeStamp) VALUES (%g, %g, %@)",newLocation.coordinate.latitude, newLocation.coordinate.longitude, newLocation.timestamp]; char *error; if ( sqlite3_exec(databasehandle, [insertStatement UTF8String], NULL, NULL, &error) == SQLITE_OK) { NSLog(@"Location

How do I send the data I have in my sqlite database to the server with HTTP and JSON

坚强是说给别人听的谎言 提交于 2020-02-02 15:57:46
问题 I'm storing id,lat,lng, and timestamp in sqlite and now need to send it in an JSON object to the server. Here's where I'm inserting the data. NSString *insertStatement = [NSString stringWithFormat:@"INSERT INTO location (latitude, longitude, timeStamp) VALUES (%g, %g, %@)",newLocation.coordinate.latitude, newLocation.coordinate.longitude, newLocation.timestamp]; char *error; if ( sqlite3_exec(databasehandle, [insertStatement UTF8String], NULL, NULL, &error) == SQLITE_OK) { NSLog(@"Location

Core Data: Abstract entities and inheritance relationships

空扰寡人 提交于 2020-02-02 10:27:40
问题 My exact model is complicated to explain, so say that I'm modeling fruits and their seeds in Xcode's Core Data modeler. Here's some "pseudo Core Data code": abstractEntity Fruit attribute sweetness relationship Seed abstractEntity Seed attribute shape concreteEntity Apple inherits Fruit concreteEntity Orange inherits Fruit concreteEntity AppleSeed inherits Seed concreteEntity OrangeSeed inherits Seed The reason I modeled in this way is that I want to be able to fetch a mix of fruits and sort

iPhone - webViewDidFinishLoad not called

拜拜、爱过 提交于 2020-02-02 07:26:29
问题 I have a simple View into IB that contains just a UIWebView and a UIButton. The webView is retained, connected, not nil, the delegate property os also connected, the Controller is UIWebViewDelegate compliant and set in the .h. in ViewDidLoad, I use [self.webView loadHTMLString:htmlContent baseURL:nil] ; The content loads, but webViewDidFinishLoad is never triggered, neither didFailLoadWithError , neither webViewDidStartLoad . How can I know when my content has finished loading , as it take a

TBXML parsing complex xml into array

匆匆过客 提交于 2020-02-01 07:47:11
问题 I have an xml response that i need to set into an array. The problem is i need to access each element and store it in an array so that i can use it for a tableview. <?xml version="1.0" encoding="UTF-8"?> <Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.2sms.com/2.0/schema/0310_ResponseReportStandard.xsd" Version="1.0"> <Error> <ErrorCode>00</ErrorCode> <ErrorReason>OK</ErrorReason> </Error> <ResponseData> <Identification> <UserID

How to delete single characters in an UITextView

女生的网名这么多〃 提交于 2020-02-01 07:34:21
问题 I have an UITextView which is for instance 380 characters in length: NSLog(@"aTextView.text lenght %i", aTextView.text.length); I now want to go through this text (backwards, char by char) and delete all characters which come before the last space (e.g. if the last words were "...this is an example", it want to reduce the string to "...this is an ": for (int i = aTextView.text.length-1; i > 0; i--) { NSString *checkedChar = [NSString stringWithFormat:@"%c", [aTextView.text characterAtIndex:i]

Hiding the UINavigationBar only for the root UIViewController

南楼画角 提交于 2020-01-31 15:22:51
问题 I am using a UINavigationController (side note: inside a UITabBar) which by default gives you a UINavigationBar on the top. If I hide the bar through IB, the bar is gone not only for the root UIViewController but also for all the controllers I push onto the stack. Leaving me no (automatic) way to pop back. So how can hide the UINavigtionBar only on the root UIViewController. Switching on/off "navigationBarHidden" temporarily does not work as this looks awkward with the animation. Any other

Swift custom UITableViewCell label is always nil

感情迁移 提交于 2020-01-31 06:18:11
问题 I've been stuck with this problem for days, so I'd be really happy if someone could help. I'm trying to create a dynamic UITableView, for which I created a custom UITableView subclass and I've created a custom UITableViewCell subclass as well, because I need several UILabels and a UIButton in each cell. The cell is created, but the problem is that the value of the labels is always nil, hence the cell isn't displayed properly. This is, how the storyboard looks like, and this is what I see