Hello Guys,
I can I make motionEnded work in one of my viewController inside the tabbarcontroller.
-(BOOL)canBecomeFirstResponder
{
return YES;
}
In viewDidLoad I got
[self becomeFirstResponder];
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (motion == UIEventSubtypeMotionShake )
{
NSLog(@"motioned");
}
}
Hello,
I'm trying to get consistant behavior out of the kAudioSessionProperty_OtherMixableAudioShouldDuck property on the iPhone to allow iPod music blending and I'm having trouble. At the start of my app I set an Ambient category like so:
-(void) initialize
{
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil];
}
Later on when I attempt to play audio I set the duck property using the following method:
//this will crossfade the audio with the ipod music
- (void) toggleCrossfadeOn:(UInt32)onOff
{
//crossfade the ipod music
AudioSessionSetProperty(kAudioSessionProperty_OtherMixableAudioShouldDuck,sizeof(onOff),&onOff);
AudioSessionSetActive(onOff);
}
I call this passing a numeric "1" just before playing audio like so:
[self toggleCrossfadeOn:1];
[player play];
I then call the crossfade method again passing a zero when my app's audio completes using a playback is stopping callback like so:
-(void) playbackIsStoppingForPlayer:(MQAudioPlayer*)audioPlayer
{
NSLog(@"Releasing player");
[audioPlayer release];
[self toggleCrossfadeOn:0];
}
In my production app this exact code works as expected, causing the ipod to fade out just before playing my app's audio then fade back in when the audio finishes playing. In a new project I recently started, I get different behavior. The iPod audio fades down and never fades back in. In my production app I use the AVAudioPlayer where in my new app I've written a custom audio player that uses audio queues. Could somebody help me understand the differences and how to properly use this API?
If I try to do actions over menuItems but the actions are not running as expected.
I think code below should make the menuItem rotate by 90 degrees but when I run it, the menuItem translates from its coordinates to another coordinate then returns to its original coordinate. The complete translation takes 3 seconds.
What I need is for the menuItem to rotate by 90 degrees in place within a 3 seconds duration. Please explain where I have done wrong?
CCMenuItemImage *targetE;//Globally declared
CCMenu *menu;//Globally declared
-(id)init
{
if( (self = [super init]) )
{
isTouchEnabled = YES;
CGSize windowSize = [[CCDirector sharedDirector] winSize];
targetE = [CCMenuItemImage itemFromNormalImage:@"grossinis_sister1.png" selectedImage:@"grossinis_sister1.png" target:self selector:@selector(touch:)];
menu = [CCMenu menuWithItems:targetE,nil];
id action4 = [CCRotateBy actionWithDuration:3.0 angle:90];
[menu runAction: [CCSequence actions: action4, nil]];
menu.position = ccp(windowSize.width/2 + 200, windowSize.height/2);
[self addChild: menu z:10];
}
return self;
}
@end
Thank You.
In the method below titleForHeaderInSection, for some reason the NSLog prints out the headers twice and then the app crashes in objc_msgSend. I can't understand why this would cause the app to crash?
It would seem from research that crashes in objc_msgSend are caused by sending messages to already freed objects, but is that the case here?
My sectionNames array is populated in viewDidLoad.
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSString *title = nil;
title=[sectionNames objectAtIndex:section];
NSLog(title);
return title;
}
Thanks
hi , iam using MFMailCompose for my application every thing works fine but iam using this code for the iPad and on the end of the mail has been written Sent From My iPhone what can i do to change it to iPad ? :D
In my source code I have some lines like NSLocalizedStringFromTable(@"Info", @"en", @"Title of this view"). When I subsequently call genstrings -o en.lproj ./Classes/*.m I would not get the expected file en.strings but Localized.strings, although I've read in the genstrings-manpage that it would generate a table.strings file from NSLocalizedStringFromTable(a, table, c) function. Am I wrong? How would I create a table.strings file then?
I'm working on an animated clock application for the iPhone, and I have to pivot all the 3 nodes in the view, which I have obtained in the following code:
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
clockarm.layer.anchorPoint = CGPointMake(0.0, 0.0);
[CATransaction commit];
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanFalse forKey:kCATransactionDisableActions];
[CATransaction setValue:[NSNumber numberWithFloat:50.0] forKey:kCATransactionAnimationDuration];
CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:-60.0];
animation.toValue = [NSNumber numberWithFloat:2 * M_PI];
animation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear];
animation.delegate = self;
[clockarm.layer addAnimation:animation forKey:@"rotationAnimation"];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[CATransaction commit];
The problem it's just rotating once, ie. only 360 degree and then stopping. I want to raotate the needles indefinitely. How would I do that?
Hi guys,
I've just completed my first app and having tested I'm ready for submission.
However, despite numerous web searches and reading, I'm struggling to finalise the method required to enable me to have a different name on the app store to the name that appears under the app on the device home screen.
In the plist.info file there is reference to bundle display name, executable name, bundle name, bundle identifier, product name etc.
So, for example, say I would like the app store name to display as:
HELLO WORLD
and I would like the name below the icon on the device home screen to display as:
HELLO
How should I enter the data in the plist.info file to achieve the above?
Many thanks in advance for your help.
Gav.
Hello,
I need to make an image view animate it's self on and off of the screen. I want it to be when the user taps the screen the image slides up. Is there a relatively easy way to smoothly move the image view?
Thanks for any help
This is my method:
-(void) playOrRecord:(UIButton *)sender {
if (playBool == YES) {
NSError *error = nil;
NSString *filePath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat: @"%d", [sender tag]] ofType:@"caf"];
NSURL *fileUrl = [NSURL fileURLWithPath:filePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileUrl error:&error];
[player setNumberOfLoops:0];
[player play];
}
else if (playBool == NO) {
if ([recorder isRecording]) {
[recorder stop];
[nowRecording setImage:[UIImage imageNamed:@"NormalNormal.png"] forState:UIControlStateNormal];
[nowRecording setImage:[UIImage imageNamed:@"NormalSelected.png"] forState:UIControlStateSelected];
}
if (nowRecording == sender) {
nowRecording = nil;
return;
}
nowRecording = sender;
NSError *error = nil;
NSString *filePath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat: @"%d", [sender tag]] ofType:@"caf"];
NSURL *fileUrl = [NSURL fileURLWithPath:filePath];
[sender setImage:[UIImage imageNamed:@"RecordingNormal.png"] forState:UIControlStateNormal];
[sender setImage:[UIImage imageNamed:@"RecordingSelected.png"] forState:UIControlStateSelected];
recorder = [[AVAudioRecorder alloc] initWithURL:fileUrl settings:recordSettings error:&error];
[recorder record];
}
}
Most of it is self explanatory; playBool is a BOOL that is YES when it is in play mode.
Everything works in the simulator however, when I run it on a device, [recorder record] returns NO. Does anyone have a clue as to why this is happening?
Hi folks,
I have just started with Android with the usual Hello World project template in Eclipse. I modified the layout XML and removed the label that says "Hello World, !", and added a couple of other controls. However, these are not reflected in the app, within the emulator. When I run this app from Eclipse again it is still showing the Hello World label!
I'm sure it's something terribly simple that I have completely missed. Can someone please point me in the right direction?
Many thanks,
Dany.
I'm interested in learning Objective C for iPhone development. This is a topic which I realize has been covered to death. The qualifying difference is: I'd like to start learning beginning with the latest version (the most recent iPhone OS as of May, 2010 is ver. 3.2 and 4 beta is also out). I'd like to not have to wade through or unlearn legacy information.
Using the links I've found throughout related topics on Stack Overflow, I'll read a blog post or tutorial which will say one thing, but then the comments will say, "this is different now in version xyz." For example, I've found this a few times regarding memory management/garbage collection.
I assume that Apple's "getting started" doc.s will have the most recent info but many SO posts have said that those are not the most clear.
The Stanford iPhone course looks great, but how do I know if it still applies to the most recent versions?
Where should one start learning Objective C for iPhone development starting with version 3.2 or later without having as much exposure to legacy information?
Hi,
I have a button in a view which refuses to work. I've got in working in a blank, default view application from X-Code, but in none of my applications will it work, instead it gives me the following error.
Terminating app due to uncaught
exception
'NSInvalidArgumentException', reason:
'* -[UIViewController showVicInfo:]:
unrecognized selector sent to instance
0x3c084f0'
The debugger isn't any help either. I've made sure that I hook up the button to the file's owner (not the other way around) as well. Below is the code for the action. And I know it's not the alert view, because the breakpoint doesn't even reach there.
about.h
@interface about : UIViewController {
}
-(IBAction)showInfo:(id)sender;
about.m
-(IBAction)showVicInfo:(id)sender {
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection" message:@"You require an internet connection via WiFi or cellular network for iFirelert to work." delegate:self cancelButtonTitle:@"OK, thanks" otherButtonTitles:nil];
[myAlert show];
[myAlert release];
}
HI all,
I am having a 2 textFeild and 1 textview.
out of 2 textfeild,one textfield requires number to be filled in there.
so for that i hv provided numeric keyboard.
i m not able to dismiss numeric keyboard,since i cant c any option to hit the numeric keyboard dismiss.
is it possible to dismiss numeric keyboard
??
if yes than can anyone guide me through.
regards
shishir
how can i show a UIView using cocos2d with animation, i have used code like:
[[[Director sharedDirector] openGLView] addSubview:myView];
but this without any animation, so how can we do it?
I want to have to occasionally insert text into the UITextView text object. For example, if the user presses the "New Paragraph" button I would like to insert a double newline instead of just the standard single newline.
How can I go about such? Do i have to read the string from UITextView, mutate it, and write it back? Then how would I know where the pointer was?
Thanks
I have a class AudioManager with a member of type AudioBufferList *. (This is a struct declared in the CoreAudio framework). Since AudioBufferList is not a NSObject, I cannot retain it, so I have to alloc/free it (correct me if I'm wrong).
My question is, where is the 'right' place to free it? Currently I am doing it in the dealloc method of AudioManager. If I understand correctly, this method is invoked automatically once the release message is sent to the instance of AudioManager --- is that true? Is there any other recommended practice regarding using alloc/free on non-objects members of Objective-C objects?
Edit:
From Apples documentation:
Subclasses must implement their own
versions of dealloc to allow the
release of any additional memory
consumed by the object—such as
dynamically allocated storage for data
or object instance variables owned by
the deallocated object. After
performing the class-specific
deallocation, the subclass method
should incorporate superclass versions
of dealloc through a message to super:
Which makes things a little bit clearer - but more insights are appreciated.
Hi! I'm experiencing this strange situation. I have a UITableView where, when the user selects a cell, a long (network) process begins. So, I performed this in a background thread and I placed (in the didSelectRowAtIndexPath) a UIActivityIndicatorView as the accessory view. This is what I wrote:
UITableViewCell* cell = [self.tableView cellForRowAtIndexPath:indexPath];
UIActivityIndicatorView* activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
cell.accessoryView = activityView;
[activityView startAnimating];
[activityView release];
everything seems to work correctly, except that, if during a loading process (when the indicator is animated), I switch the view using a UITabBar, when I go back to the UITableView, the UIActivityIndicatorView that should still be there has disappeared. Any idea of what I did wrong? Thanks!
I have a table view with varying height, as defined in the heightForRowAtIndexPath. For some very odd reason, the image is "indented" to the right based on the height; if the height is low enough, the image is stuck to the left side of the cell, but as the height increases, the image for said cell is shifted rightward compared to other rows.
The result of this is a very poor looking list, with images floppily laid out in a zig-zag pattern depending on the height of each individual row.
The problem is revealed by this simple example:
- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return (indexPath.row+1) * 50;
}
Each cell is set up (simplified) as a "Subtitle" style cell with:
// ...
cell.textLabel.text = @"foo";
cell.detailTextLabel.text = @"bar";
cell.imageView.backgroundColor = [UIColor redColor]; // for debugging; i have images with transparent bg
cell.imageView.image = anImageThatIs55x50pixelsBig;
return cell;
Any ideas? My head bleeds from the wall-love-affair.
Edit: uploaded a screen which displays this. The "image" is just a screenshot of a tiny area of the screen which makes it look a little weird, but you get the picture I'm sure: http://img28.imageshack.us/img28/549/screenshot20100311at172.png
initWithData does not convert my data object into a string properly. When I check the length of the data object, it has a value.
NSMutableData* receivedData =[[NSMutableData data] retain];
NSString* json_string = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
Am I doing something wrong creating the string?
I have some data like this :
1, 111, 2, 333, 45, 67, 322, 4445
NSArray *array = [[myData allKeys]sortedArrayUsingSelector: @selector(compare:)];
If I run this code, it sorted like this:
1, 111, 2,322, 333, 4445, 45, 67,
but I actually want this:
1, 2, 45, 67, 111, 322, 333, 4445
How can I implement it? thz u.
I'm successfully setting a date-picker with an initial date from a plist, but I see some unwanted blue values in the month, day, and year components, presumably corresponding to current date. So if today is April 18, 2010 and initial date being set is March 19, 2008, it looks like this (bold represents the blue):
January 17 2006
February 18 2007
------------------------------
March 19 2008
------------------------------
April 20 2009
May 21 2010
First question is: How do I get rid of the blue?
And second question: Ideally, how do I get it to look like this?
January 17 2006
February 18 2007
------------------------------
March 19 2008
------------------------------
April 20 2009
May 21 2010
Third question, totally unrelated and not as important: How could I have gotten the above to show in blue rather than bold? I see blue in code snippets all the time.
Matt
I am using a predicate to find an object in core data. I can successfully find the object that I want, but I need to also get the indexPath of that object, so that I can push a details view in for that object. Currently I have the following code for getting my object:
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:[NSEntityDescription entityForName:@"Ride" inManagedObjectContext:self.managedObjectContext]];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"title = %@ AND addressFull = %@", view.annotation.title, view.annotation.subtitle];
[fetchRequest setPredicate:predicate];
NSMutableArray *sortDescriptors = [NSMutableArray array];
[sortDescriptors addObject:[[[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES] autorelease]];
[sortDescriptors addObject:[[[NSSortDescriptor alloc] initWithKey:@"addressFull" ascending:YES] autorelease]];
[fetchRequest setSortDescriptors:sortDescriptors];
[fetchRequest setReturnsObjectsAsFaults:NO];
[fetchRequest setPropertiesToFetch:[NSArray arrayWithObjects:@"title", @"addressFull", nil]];
NSError *error = nil;
NSArray *fetchedItems = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
// Sohow what record we returned
NSLog(@"%@",[fetchedItems objectAtIndex:0]);
So, I can correctly get my object into an array. But how do I translate that object into an indexPath?