cocoa-touch

Core Text's CTFramesetterSuggestFrameSizeWithConstraints() returns incorrect size every time

江枫思渺然 提交于 2019-12-29 03:11:12
问题 According to the docs, CTFramesetterSuggestFrameSizeWithConstraints () "determines the frame size needed for a string range". Unfortunately the size returned by this function is never accurate. Here is what I am doing: NSAttributedString *string = [[[NSAttributedString alloc] initWithString:@"lorem ipsum" attributes:nil] autorelease]; CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef) string); CGSize textSize =

Can I develop my own objective-C Framework for Cocoa Touch Applications?

孤街醉人 提交于 2019-12-29 03:10:26
问题 Is it possible to create an own obj-C Cocoa Touch framework which can be used by other developers? And furthermore can you protect this framework? 回答1: I've created templates for Xcode 4 that allow you to build universal iOS frameworks (which work in both device and simulator). Once the templates are installed, you simply select "Static iOS Framework" when creating a new project and it does the rest. It also works with unit tests. https://github.com/kstenerud/iOS-Universal-Framework 回答2: You

Core Data: UITableView with multiple NSFetchedResultControllers

白昼怎懂夜的黑 提交于 2019-12-29 02:57:39
问题 What I want to do is pretty simple. In my UITableViewController, I want to load data from multiple NSFetchedResultControllers (I have multiple entities in my data model) and put data from each one into a different section in the table view. So for example, all the fetched items from the first NSFetchedResultController would go in section 0 in the UITableView, the fetched items from the other one goes into section 1, etc. The Core Data template project doesn't demonstrate how to do this.

Why does UITableViewCell remain highlighted?

痞子三分冷 提交于 2019-12-29 02:24:07
问题 What would cause a table view cell to remain highlighted after being touched? I click the cell and can see it stays highlighted as a detail view is pushed. Once the detail view is popped, the cell is still highlighted. 回答1: In your didSelectRowAtIndexPath you need to call deselectRowAtIndexPath to deselect the cell. So whatever else you are doing in didSelectRowAtIndexPath you just have it call deselectRowAtIndexPath as well. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:

Problems with PHP and MySQL

我的梦境 提交于 2019-12-29 01:57:27
问题 I am working within Xcode and have an iOS application that you input information and the app connects to a DB via a PHP file. There is no problem when uploading, a name or an email address. But for some reason when it comes to uploading a good amount of text, via a UITextView , there becomes a problem. It succeeds when there are no punctuation at all. But when there is a period, or a question mark, it does not get uploaded to the server, it just fails. But with the email field, there is no

How or where should I store object instances that I require globally within my iOS app?

╄→尐↘猪︶ㄣ 提交于 2019-12-29 01:44:09
问题 I'm building an iOS application. Most of the application requires access to a persistent object. This object is instantiated when the app loads via the Application Delegate. The problem I have is that numerous View Controllers that need to access this object. What is the best way and best practice to create global objects that can be access from anywhere in the application? Examples would be appreciated. Many thanks. 回答1: You might want to look at the Singleton pattern. The linked article

Compare the text of two text fields

十年热恋 提交于 2019-12-29 01:43:07
问题 How do you compare the text in two text fields to see if they are the same, such as in "Password" and "Confirm Password" text fields? if (passwordField == passwordConfirmField) { //they are equal to each other } else { //they are not equal to each other } 回答1: In Objective-C you should use isEqualToString:, like so: if ([passwordField.text isEqualToString:passwordConfirmField.text]) { //they are equal to each other } else { //they are *not* equal to each other } NSString is a pointer type.

Unable to programatically create a UIViewController in Swift

爱⌒轻易说出口 提交于 2019-12-29 01:37:14
问题 When I try to create an instance of a UIViewController in Swift , all the inherited initialisers are unavailable, even though I didn't define any designated inits in the view controller (or anything else, FWIW). Also, if I try to display it by making it the root view controller, it never gets displayed: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. window

Retrieving the serial number from the device

不羁岁月 提交于 2019-12-29 00:07:09
问题 How do we get the serial number of the device through objective C? I want to retrieve the iPod/iPhone/iPad serial number from within my application. 回答1: If you are creating an application that will not be submitted to the App Store you can check out Erica Sadun's UIDevice Extensions which uses IOKit.framework. [[UIDevice currentDevice] serialnumber] 来源: https://stackoverflow.com/questions/7127614/retrieving-the-serial-number-from-the-device

Convert NSString of a math equation to a value

折月煮酒 提交于 2019-12-29 00:07:06
问题 I would like to know how to evaluate a string representation of an equation as if it were a real equation: if(@"15+14==23") { //True statement... } else { //False statement.... } I want to return "false" because 15+14 does not equal 23. How can I get this to work? 回答1: Here is an example how to do it with NSPredicate : NSPredicate *p = [NSPredicate predicateWithFormat:@"1+2==3"]; NSLog(@"%d", [p evaluateWithObject:nil]); p = [NSPredicate predicateWithFormat:@"1+2==4"]; NSLog(@"%d", [p