cocoa-touch

Getting a specific song from a specific playlist

三世轮回 提交于 2020-01-17 13:20:48
问题 Let's say i want to order by name all songs from a specific, say "My playlist", Playlist, and play song 100 in that playlist. Is it possible at all? 回答1: I haven't tested this, but the code below is a start to retrieve a playlist and play its 100th item. However, it does not sort the playlist by tite. For that, you could iterate over the playlist items, retrieve all their names, and put the names into a dictionary with the MPMediaItem objects as keys (don't know if this works). You can then

How to quit iPhone app with an “intentional exception”?

蹲街弑〆低调 提交于 2020-01-17 11:28:08
问题 I know Apple frowns upon closing the app because the user might think it crashed. So how do I make it quit intentionally with an exception that doesn't get caught when the user goes back to the home screen? Also, would this be rejected by the App Store? 回答1: Please see the answer to this question: Forcing a background application to terminate in iOS simulator It will tell you how to setup your application to terminate instead of backgrounding when the user hits the home button. If you don't

bootstrap server. Error in iPhone SDK

橙三吉。 提交于 2020-01-17 08:32:18
问题 Can anyone help for the following ERROR: Couldn't register com.india.XXX with the bootstrap server. Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger. here m using xcode 4.1 and i have same project folders in my local desk. When ever i open multiple projects with the same name its showing the above error. Thanks in advance. 回答1: Some of the fixes that the links Saif contain may work for some, but not for me. I

How to handle freezing programm at loading xml from bad url?

☆樱花仙子☆ 提交于 2020-01-17 07:55:28
问题 I want to handle freezing my program, when it load an xml from bad address. I tryed it with using @try and @catch, but it doesn't work. Can I use some alternative handling? @try{ NSString *test=[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@:%@",addressLabel.text,portLabel.text]] encoding:NSUTF8StringEncoding error: nil]; } @catch (NSException *ex) { NSLog(@"Bad IP address"); return; } 回答1: Run your XML Parser in NSThread and use

Interface Orientation won't change to Landscape on App Launch

风格不统一 提交于 2020-01-17 05:49:05
问题 i stuck on a problem that drives me crazy! I have an iPad application starting with a TabBarViewController. Every Tab has it's own ViewController and nib-file. To make interface orientation possible I added all orientations to my info.plist and subclassing my TabBarController to set: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } Every View is autoresized and formatted well for displaying the right Orientation if I rotate the

Get UISegmentedController value from flipside

↘锁芯ラ 提交于 2020-01-17 05:21:17
问题 If you just have a utility template provided by SDK with a segmented controller on the flipsideview with several segments of a decimal value, and you want to grab the current value for the mainview, what is the best way to do this? Thank you for taking the time to answer! MainViewController.m -(void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller { [self dismissModalViewControllerAnimated:YES]; //This does get the value, but only by going to the flipside first then back

Get UISegmentedController value from flipside

大憨熊 提交于 2020-01-17 05:20:05
问题 If you just have a utility template provided by SDK with a segmented controller on the flipsideview with several segments of a decimal value, and you want to grab the current value for the mainview, what is the best way to do this? Thank you for taking the time to answer! MainViewController.m -(void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller { [self dismissModalViewControllerAnimated:YES]; //This does get the value, but only by going to the flipside first then back

Move a button in the screen

不羁的心 提交于 2020-01-17 04:56:31
问题 I have an UIButton and I want to move that button by touching and swiping it in the screen. When I release the touch it will be in the current position. Explain clearly, please. 回答1: You can move a view by using touch moved event. There is a sample tutorial MoveMe by Apple which drags a view and after releasing the touch animate the view. Check specially the touch events (touchesBegan, touchesMoved, touchesEnded) in MoveMeView.m to get the idea how they have moved placardView. You can move

Help With NSNotifcation and Asynchronous Downloading

我们两清 提交于 2020-01-17 04:14:12
问题 I am sending a notification from one view to another view. My problem is that the notification in the view that I am calling in my cellForRowAtIndexPath method is only getting sent when the tableview is scrolling. How can I stop this and make it send the notification once the images have downloaded? Here is my code: https://gist.github.com/756302 Thanks MKDev 回答1: as far as I understand your code, the message will trigger the reload of the whole table. That should lead to a refresh of the

How to repeatedly perform an action when a button is continuously pressed in obj-c

守給你的承諾、 提交于 2020-01-17 03:58:05
问题 I've got four simple methods, four buttons and one object. - (IBAction)left:(id)sender{ object.center = CGPointMake(object.center.x - 5, object.center.y); } - (IBAction)right:(id)sender{ object.center = CGPointMake(object.center.x + 5, object.center.y); } - (IBAction)down:(id)sender{ object.center = CGPointMake(object.center.x, object.center.y + 5); } - (IBAction)up:(id)sender{ object.center = CGPointMake(object.center.x, object.center.y - 5); } When I press a button, the method is executed