cocoa-touch

Why must I define variables twice in the Header file?

余生颓废 提交于 2019-12-31 01:46:12
问题 Why must I define variables twice in the header file? What differences are there between these variables? The first definition is here: @interface MyController: UIViewController { NSInteger selectedIndex; } The second definition is here: @property (nonatomic) NSInteger selectedIndex; 回答1: What you're seeing was required in earlier versions of Objective-C, but isn't any more. In the first versions of Objective-C used by NeXT up until the new runtime was introduced (with Objective-C 2.0 on Mac

How to reference HTML anchor?

雨燕双飞 提交于 2019-12-31 01:43:54
问题 I'm loading a string of HTML into a UIWebView through loadHTMLString. It produces a very long webpage. Once that string is loaded, I need to navigate to an HTML anchor tag with its "name" attribute set. In the HTML, I might have: //3 pages of text here <a name="go here"></a> lots more text here //another 3 pages of text here I need the webpage to scroll down to "go here" once loaded. The mappings work fine if a user clicks a link inside of the webpage and it loads an external URL. But in this

IBDesignables and traitCollection in live rendering

有些话、适合烂在心里 提交于 2019-12-31 00:57:25
问题 I am building my custom UIControl, a custom button built as an IBDesignable, which needs to change based on the size class in which it is being displayed. I have a method -setupForTraitCollection, which looks like this: func setupForTraitCollection() { switch(traitCollection.horizontalSizeClass, traitCollection.verticalSizeClass) { case (.Regular, _): // iPad - not compressed design compressed = false default: // iPhone - compressed design compressed = true } } This code works great when

How to make an immutable readonly property in the header file (.h), a mutable readwrite property in implementaion (.m)

依然范特西╮ 提交于 2019-12-31 00:57:09
问题 I have an object that holds a dictionary JSONData . From the header file, and to the other classes that'll access it, I want this property to only be read-only and immutable. @interface MyObject : NSObject @property (readonly, strong, nonatomic) NSDictionary *JSONData; @end However, I need it to be readwrite and mutable from the implementation file, like this, but this doesn't work: @interface MyObject () @property (readwrite, strong, nonatomic) NSMutableDictionary *JSONData; @end

Dividing a project into multiple Xcode project files

时间秒杀一切 提交于 2019-12-31 00:55:49
问题 An iPad project I have been working on has become bloated with a huge number of files. The application is a prototype and we are considering ways to prevent this when we rewrite it. One of the members of our team suggests dividing all of the components into separate Xcode projects which will be included in a master Xcode project. Is this a good idea? What are the reasons, if any, to avoid dividing features/components/controls into separate Xcode projects? 回答1: Now with Xcode4 you can create a

Adding UIImageViews to UIScrollView

十年热恋 提交于 2019-12-30 18:55:45
问题 I am currently researching ways of adding several UIImageView to a single UIScrollView . The UIScrollView will be 1.5 times the size of any one of the UIImageViews . I want to create a scrolling effect for browsing through some small images in an iPad application. Does anyone know how to achieve this? 回答1: UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(/*FRAME*/)]; // this makes the scroll view - set the frame as the size you want to SHOW on the screen [scrollView

NSURLConnection timing out on iOS8

你离开我真会死。 提交于 2019-12-30 18:55:26
问题 I have been working on an application involving client-server communication. Everything was working fine until iOS 7.1. Now that Xcode 6 GM Seed in launched, I tried to build and run the project on iOS8 simulator. However, all NSURLConnections seem to time out now. I can not get any response from the server. This works on iOS 7 simulator and Xcode 6. I tried using the NSURLSession hoping that would resolve the issue. But it hasnt. Any help will be highly appreciated!! If anyone else has faced

Enable HDR Option for UIImagePickerController

夙愿已清 提交于 2019-12-30 18:25:53
问题 Is it even possible to enable the HDR option from within my application? I assumed it would be there automatically. I looked for additional mediaTypes, thinking maybe kUTTypeHDRImage might be an option, but no such luck. It's not an additional source type, nor is it available through cameraCaptureMode. ipc.sourceType = UIImagePickerControllerSourceTypeCamera; ipc.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeImage]; No mention of it in the documentation: http://developer.apple.com

Setting UITableView headers from NSFetchedResultsController

纵饮孤独 提交于 2019-12-30 18:01:07
问题 I have a NSFetchedResultsController which is fetching objects from a NSManagedObjectContext . I'm using the results to populate a UITableView. I'm filtering with these two sort descriptors. NSSortDescriptor *lastOpened = [[NSSortDescriptor alloc] initWithKey:@"lastOpened" ascending:NO]; NSSortDescriptor *titleDescriptor = [[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES]; And when I create the NSFetchedResultsController , I sort the sections via sectionNameKeyPath:@"lastOpened" .

If statement with dates

◇◆丶佛笑我妖孽 提交于 2019-12-30 14:20:55
问题 what I am trying to do is make a if statement with dates using greater than less than signs. For some reason only the greater than sign works. Here is my code: NSDate *currDate = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; [dateFormatter setDateFormat:@"HHmm"]; NSString *dateString = [dateFormatter stringFromDate:currDate]; NSLog(@"%@",dateString); if (dateString < @"0810" && dateString > @"0800") { NSLog(@"Homeroom"); } else { NSLog(@"no"); } The output for