Does anyone sucessfully replicate this objc method in swift? I still can't make it successful in init method.
self=[[[NSBundle mainBundle] loadNibNamed:#"DGNodeView" owner:nil options:nil] firstObject]
I still can't find a good answer that is clearly working with xcode 6.0.1
Related
)
I develop a framwork along with a testApp that both belongs to the same workspace.
I added a file to my framework, it is in the Copy Ressources part of the Build Phases, I double checked the name, no issues here. I want to load this file using pretty straightforward code using [NSBundle bundleForClass: [self class]] as follows
NSBundle *bundle = [NSBundle bundleForClass: [self class]];
NSString *jsonPath = [bundle pathForResource:#"deviceSafeAreas" ofType:nil];
It always returns nil. The strange part is that if I print the bundlePath iVar, I get the same path for both [NSBundle mainBundle] and [NSBundle bundleForClass: [self class]]. I even tried to "force" the [self class] into [MyClass class], but I get the same result. If I inspect the derivedData, the file is present at the root of the framework
This folder is inside ~/Library/Developer/Xcode/DerivedData/XXXXXX/Build/Products/Debug-iphonesimulator
I also tried to create a bundle folder and add my file to it. Still the same issue : the bundle is in the framework folder, but the path is wrong.
The framework is set as "do not embeed". If I choose Embeed, I can access it through the Framework directory, but it's not a fix since our framework is available through cocoapods and not embeeded in the projects :-/
Any help would be appreciated. thanks.
in interface builder there is property of UIButton under Accessibility that says "Plays Sound".
Can any one explain what is this. Actually i am making an application which play sound on every button click and i can disable sounds from setting screen. Will this property of UIButton can help me?
Thanks
You can use [[UIDevice currentDevice] playInputClick]; to play the keyboard input click sound which is available in UIDevice. Check this apple documentation for more details.
You need to do the following for this,
Adopt the UIInputViewAudioFeedback protocol in your input view class.
Implement the enableInputClicksWhenVisible delegate method to return YES.
Do this in UIView class,
#interface MyView : UIView <UIInputViewAudioFeedback>
Then implement enableInputClicksWhenVisible method
- (BOOL)enableInputClicksWhenVisible
{
return YES;
}
If you are facing issues with this, you can check this.
The answer to your original question of whether you can use the Plays Sound 'property' (it's probably not actually a property) to make your buttons play sound is: No. Plays Sound is a 'Trait' that describes the Accessibility of an object (in this case a button) for people who are using VoiceOver (i.e. most likely people who are blind). You can read the documentation here.
hey you want to play sound on button click event then use bellow code also..
-(IBAction)playSound:(id)sender
{
NSString *path = [[NSBundle mainBundle] pathForResource:#"adriantnt_release_click" ofType:#"mp3"]; /// set .mp3 name which you have in project
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate=self;
[theAudio play];
}
and use like bellow..
-(IBAction)yourButton_Clicked:(id)sender
{
[self performSelector:#selector(playSound:) withObject:sender];
//your code write here
}
Note: Add AudioToolbox.framework Framework And also import
#import<AVFoundation/AVAudioPlayer.h> in .h file and also add Delegate AVAudioPlayerDelegate in .h file
i hope this help you...
I have subclassed UIControl to create my custom control, but I have designed it using Interface Builder. Now I want to "export" it and use it for another application and I don't know exactly what I should do in order to be able to reuse it. It loads using initWithCoder.
I have searched quite a bit on the Internet, but I haven't find a right answer for my question.
Thank you.
Maybe you need use the following code in viewDidLoad of ViewController method:
CustomControl *control = [[[NSBundle mainBundle] loadNibNamed:#"CustomControl" owner:nil options:nil] objectAtIndex:0];
control.frame = CGRectMake(5.0f, 0.0f, 310.0f, 180.0f);
[self.view addSubview:control];
I have a strange problem with MediaPlayer or AVFoundation. At some random point in the app, it stops working. With MPMoviePlayerViewController for instance it is automatically dismissed without playing the movie; with [AVURLAsset URLAssetWithURL:movieURL options:nil];
it returns nil.
The thing is that when I close the app, also from the OS background, and restart it, it will start working again.
My question is if why does it happen, or if it is a way of reset something so it could start working again. Thanks.
Hard to tell without seeing any code, but, if [AVURLAsset URLAssetWithURL:movieURL options:nil]; is returning nil, then my guess would be that movieURL is no longer valid.
How are you creating movieURL? How are you releasing it?
My suggestion is to set a breakpoint where you call [AVURLAsset URLAssetWithURL:movieURL options:nil]; and check the value for movieURL. I am willing to be that it will be nil when the movie fails to load.
I see this output in allocations tool(one of too many warnings) Can anyone tell me what is going bad here? something with the UIImage and something very wrong with how I create/use navigation controller
And this is my category for imageview in APP_CATEGORIeS class import
#implementation UIImage(APP)
+(UIImage *) APP_IMAGE_BCKGROUND {
NSString *path = [[NSBundle mainBundle] pathForResource:#"bckPhone" ofType:#"png"];
return [UIImage imageWithContentsOfResolutionIndependentFile:path];
}
Looks like you have a UIImage in a past view that wasn't released that's causing dirty leak. Make sure your view transitions are smooth (allocations wise).
On a separate note, if you're setting two different anImageView images and it's retained in another class then Xcode and the compiler might not be catching it and warning you, however that'll do nasty things when the code is executed.