cocoa-touch

Exception if nil or <null>

二次信任 提交于 2020-01-03 04:51:06
问题 Im pull the location of a pic from a php script and if there is no picture location it displays "null" for the location in the JSON output. This is throwing an exception in my code. Here is the code which is not working: NSString *piclocation = picloc; if(piclocation == nil || @"null"){ }else{ NSString *mutableUrlString = @"https://www.mypage.com/uploads"; mutableUrlString = [mutableUrlString stringByAppendingString: piclocation]; NSLog(mutableUrlString); NSURL *url = [NSURL URLWithString:

Exception if nil or <null>

扶醉桌前 提交于 2020-01-03 04:51:05
问题 Im pull the location of a pic from a php script and if there is no picture location it displays "null" for the location in the JSON output. This is throwing an exception in my code. Here is the code which is not working: NSString *piclocation = picloc; if(piclocation == nil || @"null"){ }else{ NSString *mutableUrlString = @"https://www.mypage.com/uploads"; mutableUrlString = [mutableUrlString stringByAppendingString: piclocation]; NSLog(mutableUrlString); NSURL *url = [NSURL URLWithString:

Waiting for UITextView to Finish Updating Text (iOS 7.1)

佐手、 提交于 2020-01-03 04:32:21
问题 I'm programatically updating the attributedText of a UITextView . Following the update I want to call setContentOffset so that I can scroll to position the new text. The problem I'm having is that there's a delay in the text view updating its text. With the following code the debug log outputs the same value: - (void)appendToTextView:(NSString*)text { CGFloat bottomOfCurrentContent = _pastedText.contentSize.height; NSLog(@"Bottom of content, before = %f", bottomOfCurrentContent); NSString*

How can I create a UIButton supporting dynamic multiline text with image background?

最后都变了- 提交于 2020-01-03 04:25:14
问题 I'm trying to create a UI element on iOS that expands or contracts to fit dynamic, often multiline text. I need to put an image underneath the text that looks a lot like a message bubble. However, I only need one of these in my entire UI, so a table view seems overkill - unless reasonably necessary. I've tried to use a UILabel for this purpose, but it seems to have very limited support for background images. I can only get it to tile the image, which is not what I want. It seems that a

dynamically add Items to TTLauncher

▼魔方 西西 提交于 2020-01-03 03:25:12
问题 in my app i got a TTLauncher Object with some TTLauncherItems in it. Now i want to add some Items dynamically inside my App by pressing a button. Is there a simple way to do that or do i have to create my own methods? In the original facebook application there is already something like that implemented. (You can add your Friends to the Launcher) If not, what would be the best thing to do something like that? Store all "extra items" in a plist oder even in a database and query them, each time

UITableView - SelectedBackgroundView not working in iOS7 with Auto-Layout

谁说胖子不能爱 提交于 2020-01-03 03:22:49
问题 I am using UITableVeiw with static cells in iOS7. The table view looked like this before I converted my storyboard to use autolayouts. I am using the "background view" property and the "selectedBackgroundView" property of the tableviewcell to set backgrounds like so: After enabling auto-layout though in the storyboard, the layout goes bonkers and this is what I am left with: I don't have any auto-layout issues that are presented to me. Just that I am not seeing the foreground and background

Semi-Transparent UITableViewCells are not transparent until they have been scrolled off screen

扶醉桌前 提交于 2020-01-03 03:11:09
问题 [FIXED] After trying quite a few different solutions I finally got one to work. All I needed to do was set the cell backgroundColor to clear in the willDisplayCell method: - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath [cell setBackgroundColor:[UIColor clearColor]]; My UITableview has a background image (Photo) and the cells in the table view have a semi-transparent background. When i first show the UITableView the

Where can I store the iOS device token for later use?

限于喜欢 提交于 2020-01-03 02:59:10
问题 Right now I'm getting the device token via didRegisterForRemoteNotificationsWithDeviceToken . However, I need to use the device token later on in my application after my user logs in. How can I access the deviceToken from elsewhere in application later on, and if I cannot, how/where can I store it in didRegisterForRemoteNotificationsWithDeviceToken so I can retrieve it later on? 回答1: The most simple way is to use NSUserDefaults Saving: NSUserDefaults * ud = [NSUserDefaults

Getting a error with implicit conversion of an pointer using Automatic reference Counting Issue

僤鯓⒐⒋嵵緔 提交于 2020-01-03 02:54:10
问题 I am getting an error Implicit conversion of an Objective-C pointer to 'void' is disallowed with ARC -(void)openAnimation { NSValue *contextPoint =[NSValue valueWithCGPoint:self.view.center]; [UIView beginAnimation:nil context:contextPoint]; // getting error here } Can anyone help me to solve this error Thank you 回答1: So first, I would point out that this type of thing is easier to do with the block based animation methods. For iOS4 and iOS5, Apple recommends that you use those newer methods

performance of nspropertylistserialization vs nsjsonserialization

蓝咒 提交于 2020-01-03 02:40:07
问题 I'm considering making a switch from serializing data from my web service endpoint as JSON to a binary property list. I'm unserializing on Cocoa. Has anyone who has used both NSPropertyListSerialization and NSJSONSerialization noticed a difference in parsing times? I'm curious as I've read before that there's a noticeable difference—see this blog post (in the Under the Hood section) for an example by Hipmunk. Also interesting to me if there's a noticeable difference between