cocoa-touch

How do I prepare my UI in a background thread?

喜欢而已 提交于 2020-01-03 02:29:07
问题 A UIViewController takes about half a second to load its contents and appear on screen. How can I make them all load in the background and appear when they're ready? 回答1: There is a LazyTableImages sample on the Apple developer site. It shows how to perform the heavy lifting in a background thread and update the UI on the main thread. PerformSelectorInBackground:withObject: is a possible solution, although a more modern method would be to use asynchronous blocks. You can run code on the main

Help with Modal View Controller & Login

China☆狼群 提交于 2020-01-03 00:57:33
问题 I need some help with modal view controllers, as I have not used Modal View Controllers before... So this is how my application now is... - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [_window addSubview:rootController.view]; rootController.selectedIndex =2; NSLog(@"Displaying the APP delegate"); [self.window makeKeyAndVisible]; return YES; } I have a view for Login,

Safe way of iterating over an array or dictionary and deleting entries?

倾然丶 夕夏残阳落幕 提交于 2020-01-02 20:29:30
问题 I've heard that it is a bad idea to do something like this. But I am sure there is some rule of thumb which can help to get that right. When I iterate over an NSMutableDictionary or NSMutableArray often I need to get rid of entries. Typical case: You iterate over it, and compare the entry against something. Sometimes the result is "don't need anymore" and you have to remove it. But doing so affects the index of all the rows, doesn't it? So how could I safely iterate over it without accidently

Objective-C - How can I convert Byte Array to NSString?

[亡魂溺海] 提交于 2020-01-02 20:26:11
问题 I am trying to convert a byte array into a NSString object. For testing purposes I am then just trying to print out the contents of the string to the log. Here's what I got: UInt8 buf[BUFSIZE]; CFIndex bytesRead = CFReadStreamRead(stream, buf, BUFSIZE); if (bytesRead > 0) { NSString *serverText = [[NSString alloc] initWithBytes:buf length:(NSUInteger)BUFSIZE encoding:NSASCIIStringEncoding]; NSLog("%@",serverText); [serverText release]; I am trying to initialize a new NSString using

Is it possible to use iOS 7 UIViewController transitions (interactive specifically) with child view controllers?

▼魔方 西西 提交于 2020-01-02 15:25:26
问题 There's many tutorials floating around about using the new iOS 7 UIViewController transitions API and the great new interactive transition API. However, none of these seem to reference adding and removing child view controllers interactively, despite in the WWDC 2013 video on Custom UIViewController Transitions the Apple employee shows what I would imagine to be a child view controller presented with a custom transition: (I'm assuming this as a view controller is shown on top of another one

iPad Pro scale up from iPad application and Launch Screen file - iOS 10

ぐ巨炮叔叔 提交于 2020-01-02 14:37:30
问题 I have an ipad application that I would like to run on iPad pro, but when I run it, it only occupies one corner of the screen like so: Now, another stackoverflow question asked the same question and the response was to remove the launch screen file and not to give the OS any hardcoded information about the device size it's going to run on. I did it and it scaled my app to full screen BUT.. It created another iOS10 specific bug that happens if you don't specify the launch screen: iPad

How to record all of the user's touches in iPhone app

ぐ巨炮叔叔 提交于 2020-01-02 14:08:09
问题 note: This is an expansion (and clarification) of a question I asked yesterday. I am conducting a research project where I want to record all of the user's touches in the iPhone app. After the experiment, I will be able to download the data and process it in either Excel or (more likely) Matlab and determine how many times they clicked on certain buttons, when they clicked certain buttons, etc. To do this, I would need to know: a) When they touched b) Where they touched c) Which view they

NSData writeToFile not completely written when reading

馋奶兔 提交于 2020-01-02 13:13:35
问题 I am writing an iPhone app that allows you to browse images in one view, and create them in another. The view that creates an image will write the image to the documents folder using the following code (when tapping a button to dismiss the view): [UIImagePNGRepresentation(image) writeToFile:path atomically:YES]; The browser view will load the image using: UIImage *image = [UIImage imageWithContentsOfFile:path]; Now this works perfectly 9 out of 10 times. 1 out of 10 the image is not

How to unset delegate on UIView setAnimationDelegate: call?

孤街醉人 提交于 2020-01-02 12:27:59
问题 I am receiving crash reports that appear to be from a UIView animation calling a delegate that has been dealloced. Thread 0 Crashed: 0 libobjc.A.dylib 0x334776f6 objc_msgSend + 18 1 UIKit 0x31c566c4 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] 2 UIKit 0x31c565d2 -[UIViewAnimationState animationDidStop:finished:] 3 QuartzCore 0x30045a26 run_animation_callbacks I am setting the current view controller as the delegate for animations using the following pattern: [UIView

How to unset delegate on UIView setAnimationDelegate: call?

两盒软妹~` 提交于 2020-01-02 12:26:10
问题 I am receiving crash reports that appear to be from a UIView animation calling a delegate that has been dealloced. Thread 0 Crashed: 0 libobjc.A.dylib 0x334776f6 objc_msgSend + 18 1 UIKit 0x31c566c4 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] 2 UIKit 0x31c565d2 -[UIViewAnimationState animationDidStop:finished:] 3 QuartzCore 0x30045a26 run_animation_callbacks I am setting the current view controller as the delegate for animations using the following pattern: [UIView