I read data from a file and append it to a textView. I can then bring up the keyboard to edit the data. I save the data when exiting. If I used [self.myTextView resignFirstResponder] to remove the keybard and then come back to the textView I can no longer access the textView field. If I comment out the [self.myTextView resignFirstResponder] the keyboard never goes away, but the data is properly written to the textView field.Any ideas why the resignFirstResponder is causing an issue?
Post
Replies
Boosts
Views
Activity
I'm refitting old moviePlayer code to the AVPlayer. I had a part when a user selected a movie from a list of choices the movie player would appear showing the clip along with a "done" button that would take the person back to the tableview.I've gotten the movie to play but I am having trouble figuring out how to have a "back/done" buttont to dismiss the Player. Here is what I have so far:-(void)playMovie: (NSString *) fileName{ NSLog(@"in playMovie second"); NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: fileName ofType:@"mp4"]]; AVPlayer *player = [AVPlayer playerWithURL:url]; AVPlayerViewController *avMovie = [[AVPlayerViewController alloc]init]; //AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player]; avMovie.view.frame = self.view.bounds; avMovie.player = player; //playerLayer.frame = self.view.bounds; //[playerLayer setVideoGravity:AVLayerVideoGravityResizeAspect]; //[self.view.layer addSublayer:playerLayer]; [player play]; //show view controller [self addChildViewController:avMovie]; [self.view addSubview:avMovie.view]; }
In objective C, how would I pass a playerLayer to an NSNotification observer? Do I need to use NSDictionary?
When I load a jpeg image into an imageview is the default action to just rescale the width and height of the image to fill the UIImageView? If I want to maintain the aspect ratio of the original image file is using something likeimageview.contentmode = UIViewContentModeAspectFit the step to take?
I have a piece of code that works on the iPhone. I load a UIImageView, make it invisible with an alpah = 0, and then play a video over it using AVPlayerLayer. When the video is done I remove the playerLayer (in a Notification) and change my alpha of myImage to 1.Two different things happen when I use an iPad.First, the alpha property does not do anything. The UIImage is visible.Second, setting the playerLayer frame to the size of the myImage from only works when I use[playerLayer setFrame:CGRectMake(0, 0, width, height)];instead of just usingplayerLayer.frame = myImage.frameHere is the code. Thanks for anyone that can clear this up for me.-(void)playMovie2: (NSString *) fileName{ #define degreesToRadian(x) (M_PI*(x)/180.0) CGFloat height, width; NSLog(@"in playMovie2 simulation!"); NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: fileName ofType:@"mov"]]; AVPlayer *player = [AVPlayer playerWithURL:url]; playerLayer = [AVPlayerLayer playerLayerWithPlayer:player]; //cgrectmake: xfloat, yfloat, width, height if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){ height = self.view.frame.size.height; width = self.view.frame.size.width; [myImage setFrame:CGRectMake(0, 0, width, height)]; NSLog(@"iPhone %f %f",width, height); } else{ //we need this because I only used one XIB file for the iPhone and iPad //we need to get the dimension from the device height = [UIScreen mainScreen].currentMode.size.height; width = [UIScreen mainScreen].currentMode.size.width; height = (height/2); width = (width/2); [myImage setFrame:CGRectMake(0, 0, width, height)]; NSLog(@"iPad %f %f",width, height); } self.myImage.alpha = 0; //[playerLayer setFrame:CGRectMake(0, 0, width, height)]; // For some reason I need to use this playerLayer.frame = myImage.frame; //instead of this for iPad [self.view.layer addSublayer:playerLayer]; [player play];}
I have an IBOutlet in my .h file@property (nonatomic, strong) IBOutlet UIImageView *myImage;What is the difference between these assignments?playerLayer.frame = self.myImage.frame; playerLayer.frame = myImage.frame;
Does Xcode or Swift allow VOIP programming? If so, would someone point me in the right direction how I can write an app to do this. Does it require access to a service provider to allow telecommunication?
When I first wrote my simple program using in-app purchase (I did not rewrite this app from C to Swift) when the user selects a purchase from the view controller this calls a simple purchase routine. If there are purchases it will update the state of the view controller's buyButton to allow a purchase. It also updates the productTitle and productDescription.
This used to work, but with the newer Xcode I am not allowed to change the state of the button from within the thread: "Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread."
How do I enable the button then? Is using dispatch_async the correct solution?
Below is the routine that is called from the paymentQueue:
(void) productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
NSArray *products = response.products;
NSLog(@"in productsRequest");
myProduct = products;
if (products.count != 0)
{
_product = products[0];
//THIS IS WHAT IS CAUSING THE ISSUE *******
buyButton.enabled = YES;
_productTitle.text = _product.localizedTitle;
_productDescription.text = _product.localizedDescription;
}
else{
_productTitle.text = @"Product not found";
}
products = response.invalidProductIdentifiers;
for (SKProduct *product in products)
{
NSLog(@"Product not found: %@", product);
}
}
Should I be doing something like this for the UI changes:
dispatch_async(dispatch_get_main_queue(), ^{
self->buyButton.enabled = YES;
self->_productTitle.text = self->_product.localizedTitle;
self->_productDescription.text = self->_product.localizedDescription;
});
It has been 2 years since I updated one of my apps. I am trying to create a distribution provisioning profile. I am seeing that the generic wildcard profile is no longer an option. If I have 30 apps do I need to create 30 distribution profiles? Is wildcard truly not an option?