cocoa-touch

NSDateFormatter to NSString?

女生的网名这么多〃 提交于 2020-01-07 06:59:12
问题 NSDate *dateNow = [NSDate date]; NSLog(@"NSDate : %@", dateNow); NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setLocale:[NSLocale currentLocale]]; [dateFormatter setTimeStyle:NSDateFormatterLongStyle]; NSString *dateString = [dateFormatter stringFromDate:dateNow]; NSLog(@"NSDateFormatter String: %@", dateString); NSDate *dateObject = [dateFormatter dateFromString:dateString]; NSLog(@"NSDateFormatter Object: %@", dateObject); First off ignore

How to target previous version of iOS in XCode4?

二次信任 提交于 2020-01-07 05:50:26
问题 How can I target a previous version of iOS in XCode4? My app is building only for iOS 4.3 devices and I'd like users with iOS 3.0 installed to be able to run the app as well. 回答1: Select the project in the Project Navigator and the then the target in the detail view. Under the summary tab you have the Deployment Target. Set it to 3.0. Alternatively you can set the iOS Deployment Target in the build settings. Both ways change the same parameter, it's just two different ways to access it. This

UIWebView, goBack accessing back-forward list?

浪尽此生 提交于 2020-01-07 05:32:05
问题 I am just having a quick look at UIWebView and have written a small browser with a back button, a UITextField and a forward button. Here is what happens: I enter "www.google.com" into the textField and it goes to the page. The textField says "www.google.com" I enter "www.apple.com" and it goes to the page. The textField says "www.apple.com" I tap the back button and return to "www.google.com" The textField still says "www.apple.com" I have added: -(IBAction)myGoBack { NSLog(@"myGoBack ...");

How can I play a movie locally with the MPMoviePlayerViewController?

百般思念 提交于 2020-01-07 04:45:06
问题 I have an mp4 file called lebron.mp4 in my Resources folder: -(IBAction)videoButtonClicked:(id)sender{ NSString *url = [[NSBundle mainBundle] pathForResource:@"lebron" ofType:@"mp4"]; MPMoviePlayerViewController* moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:url]]; moviePlayerViewController.view.backgroundColor = [UIColor blackColor]; [self presentMoviePlayerViewControllerAnimated:moviePlayerViewController]; [moviePlayerViewController

Why doesn't setting the value property of this UISlider update its position?

故事扮演 提交于 2020-01-07 04:44:30
问题 ...ViewController.h: @property (nonatomic, strong) IBOutlet UISlider *slider; ...ViewController.m: @synthesize slider; - (void)viewDidLoad { [super viewDidLoad]; ... currentValue = 50; self.slider.value = currentValue; // Do any additional setup after loading the view, typically from a nib. } .xib: The UISlider in my interface is connected to the slider property. Behavior: The slider sits all the way to the right at value 100 when it is supposed to be in the middle. An action I set up

Is there any function to retrieve the path associated with an NSFileSystemFileNumber?

安稳与你 提交于 2020-01-07 04:22:42
问题 I am writing a utility that walks a directory tree on Cocoa and tries to detect changes that have occurred since the directory was last synchronized with a back-up location. When I initially synchronize the files and folders I obtain the NSFileSystemFileNumber and store it in the database record for that file or folder: NSString *oldFilePath = /* ... */; NSError *error = nil; NSDictionary *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:oldFilePath error:&error]; /* set

Add UiStepper programmatically inside cells

我只是一个虾纸丫 提交于 2020-01-07 02:33:06
问题 how do I add a UIStepper to every cell of my UITableView programmatically? Thanks Luca 回答1: One way to do it is to add the UIStepper to each cell as a subview in tableView:cellForRowIndexAtPath in your TableViewController. For example: - (UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* CellIdentifier = @"Cell"; UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [

iPhone: problem rotating a UIView - doesn't look right

非 Y 不嫁゛ 提交于 2020-01-07 02:32:26
问题 I am adding a simple UIView to my app. This works fine, until I use the 'transform' property to rotate it: myView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)]; myView.backgroundColor = [UIColor whiteColor]; myView.transform = CGAffineTransformMakeRotation(-0.2); [self.view addSubview:myView]; //self.view is just another generic UIView The added view is rotated, but has jagged edges - i.e. the edges have not been anti-aliased. Here's an example of what I mean: aliased vs. anti

How to show SomeViewControler using code?

谁说我不能喝 提交于 2020-01-07 02:17:25
问题 I am brand new in Xcode and iOS development. I am trying to figure out how to open/show some view based on button click. I know that I can do this using ctrl + mouse click on some ViewController using segue but I need to add some logic before. How can I accomplish this? 回答1: There are two ways to make segues work. You can either ctrl drag from a button to a new ViewController (like you have done) or you can ctrl drag from one ViewController to a new ViewController (drag from the little orange

MPMoviePlayerController causing a MP _playbackInterruptionDidEndNotification on appDidBecomeActive

对着背影说爱祢 提交于 2020-01-07 02:17:06
问题 I have a navigation controller that pushes another view which plays video files. Everything is working fine and on the simulator there is no problem at all. The problem is when I test the application on the iPhone, the movies play well but if I press the home button on the iPhone then I launch the app again I receive the following warning in Xcode Debugging area: 2011-11-21 20:23:05.216 KMW[324:707] MP _playbackInterruptionDidEndNotification :: NSConcreteNotification 0x164e90 {name =