cocoa-touch

Game Center authentication error

China☆狼群 提交于 2019-12-30 07:03:13
问题 I'm trying to call the authentication method of game center, however no authentication screen comes up and the callback return with an error : "the requested operation has been canceled". The code : [[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error) { NSDictionary *userInfo = nil; if (error == nil) { NSLog(@"Game Center successfully authenticated"); } else { userInfo = [NSDictionary dictionaryWithObject:error forKey:@"NSError"]; } [[NSNotificationCenter

Crashing while trying to move UITableView rows

假如想象 提交于 2019-12-30 06:59:05
问题 I've got some rather complicated rules for moving rows around in a UITableView . There are an undefined number of sections and rows per section, and based on various rules, rows can be moved within or between sections by the user to specific other locations. All of the data updating and everything is working. But occasionally, after moving a row, the app will wig out and suddenly there will be an empty space where a row should be displayed. I'm using: - (NSIndexPath *)tableView:(UITableView *

iPad modal view controller similar to Mail.app?

谁说我不能喝 提交于 2019-12-30 06:48:49
问题 How can I create a modal window in my iPad app similar to the one shown on Apple's website for composing messages in Mail.app? Example: http://dl.getdropbox.com/u/413086/mail_type_20100225.jpg Thanks! 回答1: Just use a normal view controller, assign the modalPresentationStyle property, and present it as a modal view controller. Please read the "iPad Programming Guide" / "Views and View Controllers" for detail. 来源: https://stackoverflow.com/questions/2485015/ipad-modal-view-controller-similar-to

Is there a way to set different CFBundleDisplayName for iPad and iPhone?

拟墨画扇 提交于 2019-12-30 06:44:12
问题 I don't know why but in iPad, the app name can be displayed completely. However, in I put the same app in iPhone with universal binary, the app name is truncated. Is there a way that I can set different app name for iPad version and iPhone version within the universal binary?? Thanks! 回答1: Yes, just set the iPad-specific name in CFBundleDisplayName~ipad . 来源: https://stackoverflow.com/questions/5466858/is-there-a-way-to-set-different-cfbundledisplayname-for-ipad-and-iphone

How to concatenate an nsstring url

谁说胖子不能爱 提交于 2019-12-30 06:41:06
问题 How can I concatenate an NSString URL? For example: http://isomewebsite.com/username=[someuservariable]&password=[somevariable] 回答1: Try with below code. NSString* myURLString = [NSString stringWithFormat:@"somewebsite.com/username=%@&password=%@", myUserName,myPassword]; NSURL *url = [NSURL URLWithString:myURLString]; Here is the blog tutorial will help you know more about Handling url authentication challenges accessing password protected servers 回答2: You can use the method stringWithFormat

how to implement cyclic scrolling on tableview

我是研究僧i 提交于 2019-12-30 06:16:29
问题 Could you please help me with circular scrolling in tableview please. I want that if I scroll down tableview, the rows should go in the reverse way -- it should appear that move back around (bottom rows go around and now come back down from the top) i.e, cyclic scrolling basically. How can I do so. Any suggestions please. Thanx in advance. 回答1: You could "fake" the cyclic scrolling repeating the same cells all over again. In the numberOfRowsInSection method, return n times the actual number

When is an autoreleased object actually released?

ぃ、小莉子 提交于 2019-12-30 05:57:11
问题 I am new in objective-c and I am trying to understand memory management to get it right. After reading the excellent Memory Management Programming Guide for Cocoa by apple my only concern is when actually an autoreleased object is released in an iphone/ipod application. My understanding is at the end of a run loop . But what defines a run loop in the application? So I was wondering whether the following piece of code is right. Assume an object @implementation Test - (NSString *) functionA {

When is an autoreleased object actually released?

耗尽温柔 提交于 2019-12-30 05:56:12
问题 I am new in objective-c and I am trying to understand memory management to get it right. After reading the excellent Memory Management Programming Guide for Cocoa by apple my only concern is when actually an autoreleased object is released in an iphone/ipod application. My understanding is at the end of a run loop . But what defines a run loop in the application? So I was wondering whether the following piece of code is right. Assume an object @implementation Test - (NSString *) functionA {

How to make UILabel wordwrap

对着背影说爱祢 提交于 2019-12-30 05:54:57
问题 Is there anyway of making a UILabel wrap to the next line or do I have to use a UITextView? 回答1: You would need to set the numberOfLines property to 0 and explicitly specify its dimensions, either in IB or programmatically. However, if you have a lot of text to display, I would recommend using a UITextView. 回答2: What you want is to adjust your label according to the content's size. In iOS 6, AutoLayout will work a charm, you should set the label to have numberOfLines = 0 In a non AutoLayout

How to make UILabel wordwrap

有些话、适合烂在心里 提交于 2019-12-30 05:54:28
问题 Is there anyway of making a UILabel wrap to the next line or do I have to use a UITextView? 回答1: You would need to set the numberOfLines property to 0 and explicitly specify its dimensions, either in IB or programmatically. However, if you have a lot of text to display, I would recommend using a UITextView. 回答2: What you want is to adjust your label according to the content's size. In iOS 6, AutoLayout will work a charm, you should set the label to have numberOfLines = 0 In a non AutoLayout