cocoa-touch

How to perform a cell deselection when a user returns to a table view?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-06 05:37:09
问题 I am using a UITableView to display a list of cells, when the user selects a cell then a new view appears by using the following code: - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self.navigationController pushViewController: detailsViewController animated: TRUE]; } By using the code above, the view is displayed correctly, but when I return back to the root table view, then the cell is still selected. I noticed, in many sdk examples, that the

Using a UIPickerView with custom values

北城余情 提交于 2020-01-06 05:31:09
问题 Im using a navigation controller and a normal view. In the view I'd like a UIPickerView with custom values in it. It would have one column with about 15 values in it. And I want the ability to add an action to each value. Is there any way I can do this using Xcode? I can't seem to find the corrent help. Cheers. 回答1: You need to look at the documentation for UIPickerViewDelegate . In order to have an action for each value you will implement pickerView:didSelectRow:inComponent: and have a

Adding array from one view to another and retaining values

半世苍凉 提交于 2020-01-06 04:30:43
问题 I have four views, with four arrays. As soon as I navigate from one view, I add that particular array to my master array. Initially this master array has nothing, and is allocated when the app runs using 'init' method. It does not have a view and it is an array from a subclass of NSObject . Finally the master array should consist of {viewarray1, viewarray2, viewarray3, viewarray4}. Each array is added to the master array when navigating to the next view. So is there anything wrong in my

How can I calculate font size for my UILabel?

断了今生、忘了曾经 提交于 2020-01-06 04:01:05
问题 I have a UILabel measuring 984x728 px with variable text. How can I calculate the maximum font size to fit the UILabel ? 回答1: Create a font larger than you would ever want (48 points is probably good). Then use this: CGFloat maxFontSize; [string sizeWithFont:font minFontSize:0 actualFontSize:&maxFontSize forWidth:maxWidth lineBreakMode: UILineBreakModeClip]; maxFontSize will hold the largest size less than 48 and greater than 0 that will fit within maxWidth . 来源: https://stackoverflow.com

How to resolve this rotation problem?

浪尽此生 提交于 2020-01-06 03:47:07
问题 For sure this is very trivial math stuff for some of you. But: When I rotate a view, lets say starting at 0 degrees and rotating forward 0.1, 1, 10, 100, 150, 160, 170, 179, 179,999, and keeping on rotating in the same direction, this happens, to say it loud and clear: BANG !!!! BAAAAAAAAANNNNNGGGG!!!! -179,9999, -170, -150, -50, 0, 50, 100, 170, 179,99, and again: BBBBAAAANNNGGG!!! -179,999, -170, -100, and so on... for sure you know what I mean ;-) Imagine you driving on a road and suddenly

Convert Dictionaries into one array

我只是一个虾纸丫 提交于 2020-01-06 03:33:13
问题 This code: for (NSDictionary *object in JSONArray) { NSMutableArray *birdtemp = [[NSMutableArray alloc] initWithObjects:object[@"case_name"], nil]; [allparts addObject:birdtemp]; } outputs this log: log: ( ( "NZXT Phantom 410" ), ( "Thermaltake MK+" ) ) I want to know what code I could use to make that log into one array like: log: ( "NZXT Phantom 410", "Thermaltake MK+" ) Json Array is: log: ( { "case_color" = White; "case_description" = ""; "case_image" = "http://sitecom/get/parts/part

“JSONValue failed” Error while fetching data from server into iPhone

℡╲_俬逩灬. 提交于 2020-01-06 03:33:06
问题 I am fetching data from server into my iPhone app. For fetching data from server, I am using HTTP Post method and for parsing data obtained I am using SBJSON Parser. When the first time my app launches, the data is not fetched. It shows the following failure log in Console. The app does not crash but just that data is not fetched. <html>Your request timed out. Please retry the request. </html> 2011-04-21 08:39:06.339 Hive[1594:207] -JSONValue failed. Error trace is: ( "Error Domain=org

Convert Dictionaries into one array

醉酒当歌 提交于 2020-01-06 03:33:05
问题 This code: for (NSDictionary *object in JSONArray) { NSMutableArray *birdtemp = [[NSMutableArray alloc] initWithObjects:object[@"case_name"], nil]; [allparts addObject:birdtemp]; } outputs this log: log: ( ( "NZXT Phantom 410" ), ( "Thermaltake MK+" ) ) I want to know what code I could use to make that log into one array like: log: ( "NZXT Phantom 410", "Thermaltake MK+" ) Json Array is: log: ( { "case_color" = White; "case_description" = ""; "case_image" = "http://sitecom/get/parts/part

How to connect to user's stream in TokBox

旧街凉风 提交于 2020-01-06 02:56:09
问题 I'm making a 1 on 1 video call app using TokBox. I'm opening a session using this code: [_session connectWithApiKey:kApiKey token:kToken]; after getting the didConnect message i'm publishing a stream on one user device using this code: _publisher = [[OTPublisher alloc] initWithDelegate:self]; [_publisher setName:@"PublishName"]; [_session publish:_publisher]; [self.view addSubview:_publisher.view]; [_publisher.view setFrame:CGRectMake(0, 0, widgetWidth, widgetHeight)]; What do I need to

Regular Expression for validating username

a 夏天 提交于 2020-01-06 01:12:52
问题 I'm looking for a regular expression to validate a username. The username may contain: Letters (western, greek, russian etc.) Numbers Spaces, but only 1 at a time Special characters (for example: "!@#$%^&*.:;<>?/\|{}[]_+=-" ) , but only 1 at a time EDIT: Sorry for the confusion I need it for cocoa-touch but i'll have to translate it for php for the server side anyway. And with 1 at a time i mean spaces or special char's should be separated by letters or numbers. 回答1: Instead of writing one