libPd XCode Sound Issue - xcode

Hi everyone,
I've made a patch with pure data to load and play samples that will then be loaded into xcode with libpd. This all works fine but when I run the xcode project I only get sound from the right channel of my headphones.
I'll attach a picture to show my patch, and you can see that the dac has a cable on each inlet, which is why I don't understand how it isn't playing the sound in both channels.
Please note I've only attached it to the top left sample for testing purposes.
Thanks in advance!
http://i46.tinypic.com/3531gmb.png
#andyvn22: is this what you are after? Sorry I'm new to XCode so I'm not too sure!
-(void)viewDidLoad {
[super viewDidLoad];
dispatcher = [[PdDispatcher alloc] init];
[PdBase setDelegate:dispatcher];
patch = [PdBase openFile:#"Patch.pd"
path:[[NSBundle mainBundle] resourcePath]];
if (!patch) {
NSLog(#"Failed to open patch!");
}
}
-(void)viewDidUnload {
[super viewDidUnload];
[PdBase closeFile:patch];
[PdBase setDelegate:nil];
}
// Omitting the remaining view controller methods...
#pragma mark - button callbacks
-(IBAction)playc1:(id)sender {
[PdBase sendBangToReceiver: #"c1"];

Try using PdAudioController's -configurePlaybackWithSampleRate:numberChannels:inputEnabled: method to set the channels to 2.

Related

LaunchServices: invalidationHandler called - iOS 8 share sheet

Seeing this error message in the logs, though not consistently, around the time that I use SLComposeViewController to open a Twitter or Facebook share sheet. I am not using any new iOS 8 API, just testing existing code on iOS 8. I see others have had this problem and even seen crashes when using other modal view controllers from the Cocoa Touch SDK.
LaunchServices: invalidationHandler called
Are there new precautions to take with SLComposeViewController and UIActivityViewController in iOS 8? Something else to consider?
Add this code after you present your activity view controller:
if ([activityVC respondsToSelector:#selector(popoverPresentationController)])
{
// iOS 8+
UIPopoverPresentationController *presentationController = [activityVC popoverPresentationController];
presentationController.sourceView = sender; // if button or change to self.view.
}
Looking at the developer forums: "That log message does not indicate any error on your part."
I had a similar problem with a UIDocumentInteractionController, where when I tapped outside it to dismiss it, or selected another app to open the document in, it would crash with the "LaunchServices: invalideationHandler called" console message displayed twice (only using iOS 8).
A workaround is to add the call to presentOpenInMenuFromRect:inView:animated to the main queue, i.e.
dispatch_async(dispatch_get_main_queue(), ^() {
[self.documentInteraction presentOpenInMenuFromRect:theRect inView:self.view animated:YES];
});
You may also need to define the sourceRect. I used the following code to display a SLComposeViewController from a tableView.
if ([controller respondsToSelector:#selector(popoverPresentationController)]) {
//get rect for this row in table
CGRect frame = [self.tableView rectForRowAtIndexPath:indexPath];
//convert table row frame to view reference
CGRect frameInView = [self.tableView convertRect:frame toView:self.view];
[controller popoverPresentationController].sourceRect = frameInView;
[controller popoverPresentationController].sourceView = self.view;
}
Regarding the auto-closing (not the crash):
I think it's probably related to the link you are trying to share. I'm seeing the same thing when trying to post music links (Spotify, SoundCloud,...). The same tweet works if I replace the link by a link to some non-media-content. I'll file radar on this to see whether it's intentional...
This gets rid of the Error message for me and works as expected. You have to get rid of the if statement that calls "isAvailableForServiceType:"
It should look like this. Happy coding.
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:#"Great fun to learn iOS programming at appcoda.com!"];
[self presentViewController:tweetSheet animated:YES completion:nil];
if ([tweetSheet respondsToSelector:#selector(popoverPresentationController)])
{
// iOS 8+
UIPopoverPresentationController *presentationController = [tweetSheet popoverPresentationController];
presentationController.sourceView = sender; // if button or change to self.view.
}

xcode presentModalViewController leaves old ViewController still active in background using AVCam

Have a problem with an application using AVCam. The application takes photos and saves them to the roll. Upon opening the app it takes the pictures perfectly and saves them just the way it should. However, once I leave that view controller to go to another view controller and then return, it saves images normal portrait images rotated 90 degrees. Very odd activities indeed.
After lots of hair pulling, I thought maybe I'm trying to run too many sessions, so I make sure I end the sessions in viewdidload and the viewdiddisappear:
-(void)viewDidUnload{
if([[self captureManager] session ]){
[[[self captureManager] session] stopRunning];
self.captureManager = nil;
}
}
-(void)viewDidDisappear:(BOOL)animated{
if([[self captureManager] session ]&&rollCancel==NO){
[[[self captureManager] session] stopRunning];
self.captureManager = nil;
}
}
Still not working. Still saving incorrectly after leaving.
I change views like so:
-(void)openMenu{
MenuViewController * vc = [[MenuViewController alloc] initWithNibName:#"MenuViewController" bundle:nil];
[self presentModalViewController:vc animated:YES];
[self dismissViewControllerAnimated:NO completion:nil];
}
Also tried:
-(void)openMenu{
[self dismissViewControllerAnimated:NO completion:^{
MenuViewController * vc = [[MenuViewController alloc] initWithNibName:#"MenuViewController" bundle:nil];
[self presentModalViewController:vc animated:YES];
[self dismissViewControllerAnimated:NO completion:nil];
}];
}
I don't need to release since I'm running on arc. This did not work as well, I wasn't even able to change screens with this option. SO, I added a timer to see if actions would keep acting after I leave the view controller:
updateTimer = [NSTimer timerWithTimeInterval: 5.0
target: self selector: #selector(autoTimer)
userInfo: nil repeats: YES];
[[NSRunLoop mainRunLoop] addTimer: updateTimer forMode: NSDefaultRunLoopMode];
-(void)autoTimer{
NSLog(#"blablabla");
}
And no big surprise, the blablabla continues to print into my console even after leaving the view controller. If I go back and forth, it will keep making new repeating timers and spam my console log.
This has got to have something to do with my application not saving correctly after returning to the screen. Which means that doing presentmodalviewcontroller does not actually remove everything from running.
Has anybody else ran into a similar issue like this or have any idea how to actually clear view controllers when switching between them?
didn't resolve the NSTimer still running in the background, but did fix the landscape thing which had nothing to do with stuff being open in the background
Found the solution here: https://stackoverflow.com/a/6335992/1688727

iOS5 Xcode: using a link within a web view to open a new view within app

Within one of my views, there is a webview that I load in a html page locally. Within this page I have a link (href) that when pressed it opens a view within the application and not a with in the webview/current view.
For example I have a button on this page that if pressed opens another view, is there any way I can do the same within a webview using a normal link?, the code I use for this button is below so is there away to get the href link in the web view link to similar code to open my new view up??
The link in the webview is a normal See view ???
#import "anotherview.h"
.....
-(void)myhereflinkBtn:(id)sender{
anotherview *newviewPage = [[anotherviewhehffvv alloc] initWithNibName:nil bundle:nil];
[UIView transitionFromView:self.view
toView: newviewPage view
duration:1.0
options: (UIViewAnimationCurveEaseInOut | UIViewAnimationOptionTransitionCurlUp)
completion:^(BOOL finished){}];
}
I hope this make sense.
Well with a bit of looking and a fresh face this morning I have manged to get 90% of what I am after working:
Using this link as help CLICK HERE i have managed to get my xcode register my link press
- (BOOL)theWebView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
if(navigationType == UIWebViewNavigationTypeLinkClicked) {
NSLog(#"LINK CLICKED:");
[webView stopLoading];
return YES;
}
return YES;
}
- (void)viewDidLoad
{
webView.delegate = self;
[super viewDidLoad];
}
Within the header file I also then added < UIWebViewDelegate >

How to rotate app with TabBar?

Hi I have a splitview app that is working fine until I add a TabBar in the rootview section. The problem is that when I add the TabBar to the rootview the app does not rotate to landscape, if I change the orientation the view remains in portrait mode.
How can I solve this?. Hope you can help
#import "SplitViewTest3AppDelegate.h"
#import "SISACWelcomeViewController.h"
#implementation SplitViewTest3AppDelegate
#synthesize window, masterViewController, splitViewController,masterViewTabBarController, searchViewController;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStyleGrouped];
UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
masterNavigationController.tabBarItem.image = [UIImage imageNamed:#"Folder.png"];
//NewsFeedsNavigationController *newsFeedsNavigationController = [[NewsFeedsNavigationController alloc] init];
SISACWelcomeViewController *sisacWelcomeViewController = [[SISACWelcomeViewController alloc] init];
UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:sisacWelcomeViewController];
searchViewController = [[UIViewController alloc] initWithNibName:#"SearchView" bundle:nil];
searchViewController.tabBarItem.image = [UIImage imageNamed:#"Search-icon.png"];
masterViewTabBarController = [[UITabBarController alloc] init];
masterViewTabBarController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, searchViewController, nil];
masterViewController.detailNavigationController = detailNavigationController;
splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:masterViewTabBarController, detailNavigationController, nil];
splitViewController.delegate = sisacWelcomeViewController;
// Add the split view controller's view to the window and display.
[window addSubview:splitViewController.view];
//[masterNavigationController.view addSubview:tab.view];
[window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[window release];
//[tab release];
[super dealloc];
}
#end
The answer below is correct. If you are adding tabs which include using the CoreDataTableView controller (that is used with the CS193P course), be sure to add a method to allow for any orientation. If not, your split view will not work correctly.
SOLVED:
I had the same issue.
Without the TabBar all is well, add the TabBar and the rotation breaks.
I guessed that there is something broken in the responder chain or view hierarchy.
So I was about to submit as a bug. So wrote a test app to demo to Apple (because they ALWAYS ask for one), and it worked. Hooray, but why?
These are my findings from the Apple docs.
From the View Programming Guide for iOS.
Split View Controller
"A split view controller must always be the root of any interface you create."
Thus they should not be embedded within a TabBar View, although I understand that there is a workaround out in the wild.
Also:
Creating a Tab Bar Interface
"Install it as one of the two root views in a split view interface. (iPad only)"
Solution:
After much more investigation, and some trial and error, I found the issue.
Of course it seems so obvious NOW.
When the SplitView tests for shouldAutorotateToInterfaceOrientation, it tests every possible view on the whole hierarchy, that is EVERY view in the MasterView, thus EVERY view in the TabBar, and EVERY view in the DetailView, thus EVERY view in the current NavigationStack.
The fly in the ointment is that a newly created ViewController does not support Landscape by default.
Where I had gone wrong was: I had created ALL of the TabBar subviews, but not written any more code yet, because I wanted to get the SplitView with TabBar working first, thus 1 of my Tab Views had not been changed from the default.

TTNavigator not opening URLs when clicking on links in TTStyledTextLabels

Trying to make a simple link clicking activity work. I think I understand TTNavigator and TTStyledLabel, but can't get it to work.
Code:
#interface SomeVc : UIViewController <TTNavigatorDelegate> {
IBOutlet TTStyledTextLabel *styledTextLabel;
}
#end
#implementation SomeVc
- (void)viewDidLoad {
[super viewDidLoad];
navigator = [TTNavigator navigator];
navigator.persistenceMode = TTNavigatorPersistenceModeNone;
navigator.delegate = self;
TTURLMap* map = navigator.URLMap;
[map from:#"*" toViewController:[TTWebController class]];
styledTextLabel.text = [TTStyledText textWithURLs:someText];
[navigator openURLAction:[TTURLAction actionWithURLPath:#"http://www.cnn.com/"]];
}
- (BOOL)navigator: (TTNavigator*)navigator shouldOpenURL: (NSURL*)URL {
NSLog(#"trying to open %#", [URL absoluteString]);
return NO;
}
#end
I.e inside a viewcontroller, get the navigator and set self to be its delegate. When a link is opened, the shouldOpenURL delgate method gets called, where I will handle the URL opening myself. (I plan to let navigator handle more of it, but want to get this simple case working first.)
I have a test call at the end of viewDidLoad: which fires the delegate method fine.
Problem: I see the styledTextLabels rendered fine with URL-s, but when I tap on those, nothing happens. They don't reach the TTNavigator for some reason and I can't understand why. Feels like I'm missing some simple connection/scaffolding somewhere, but can't figure it out.
How to make it so that the links tapped in the styledtextlabel will reach the navigator delegate? Or how else should I implement this simple case with styledtextlabel? (just want to get callbacks for url taps.)
try setting the window property :
TTNavigator* navigator = [TTNavigator navigator];
navigator.window = window;
If you don't have one you can add one
navigator.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]
You might also need:
[navigator.window makeKeyAndVisible];

Resources