Skip to main content

Posts

Showing posts with the label cocoa-touch

How to print in iOS 4.2?

I want to integrate the print functionality in my app. The document I want to print will be in .doc or .txt format. I am not very experienced in iPhone development yet, so finding it difficult to implement it by following the Apple documentation. If someone could help me by posting some sample code, will be a great help. Thanks in advance. -iPhoneDev Source: Tips4all

Add an SQLite database to an iPhone app

I am trying to learn SQLite, and I am building an iPhone app. But I would like to add an SQLite database to my building app. I have got three tutorials, but I am not clear on that code. How can I add an SQLite database to my building app? What would sample code look like? Source: Tips4all

Is it even possible to change a UIButtons background color?

This one has me stumped. Is it possible at all to change the background color of a UIButton in Cocoa for iPhone. I've tried setting the background color but it only changes the corners. setBackgroundColor: seems to be the only method available for such things. [random setBackgroundColor:[UIColor blueColor]]; [random.titleLabel setBackgroundColor:[UIColor blueColor]];

Get launch orientation of iPad app

In my iPad app, I need to run some layout code to set the proper layout depending on the orientation. By default, the layout is configured for the landscape orientation, so in the case that the app starts in portrait mode, I need to take extra action to configure the views properly for display in portrait. In my -application:didFinishLaunchingWithOptions: method, I check the orientation using [[UIDevice currentDevice] orientation] . The problem here is that it always returns portrait even if the app is starting in landscape. Is there any way around this?

Play local notification default sound when displaying UIAlertView?

I'm writing a reminders app for iPhone that displays reminders using local notifications. If a reminder goes off while the application is running, the local notification isn't displayed. Instead, the didReceiveLocalNotification method is called in my app delegate, and I mimic the local notification dialog by displaying a UIAlertView with the reminder text. When local notifications are displayed outside of the app, the device vibrates and the sound specified by UILocalNotificationDefaultSoundName is played. Again, I'd like to mimic this in the app when displaying the UIAlertView . I can vibrate the device by calling AudioServicesPlaySystemSound(kSystemSoundID_Vibrate) , but I can't figure out how to play the local notification default sound. There's no equivalent SystemSoundID constant, and I'm not sure what the path would be. tl;dr I'd like to play the local notification default sound when displaying a UIAlertView. Any ideas?

When does an associated object get released?

I'm attaching object B via associative reference to object A. Object B observes some properties of object A through KVO. The problem is that object B seems to be deallocated after object A, meaning its too late to remove itself as a KVO observer of object A. I know this because I'm getting NSKVODeallocateBreak exceptions, followed by EXEC_BAD_ACCESS crashes in object B's dealloc. Does anyone know why object B is deallocated after object A with OBJC_ASSOCIATION_RETAIN? Do associated objects get released after deallocation? Do they get autoreleased? Does anyone know of a way to alter this behavior? I'm trying to add some things to a class through categories, so I can't override any existing methods (including dealloc), and I don't particularly want to mess with swizzling. I need some way to de-associate and release object B before object A gets deallocated. EDIT - Here is the code I'm trying to get working. If the associated objects were released

iOS UIImagePickerController result image orientation after upload

I am testing my iPhone application on an iOS 3.1.3 iPhone. I am selecting/capturing an image using a UIImagePickerController : UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera]; [imagePicker setDelegate:self]; [self.navigationController presentModalViewController:imagePicker animated:YES]; [imagePicker release]; - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { self.image = [info objectForKey:UIImagePickerControllerOriginalImage]; imageView.image = self.image; [self.navigationController dismissModalViewControllerAnimated:YES]; submitButton.enabled = YES; } I then at some point send it to my web server using the ASI classes: ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://example.com/myscript.php"]]; [request setDelegate:self]; [request setStringEnc

NSLog with CGPoint data

I have a CGPoint called point that is being assigned a touch: UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; I want to get the x coordinate value into my console log: NSLog(@"x: %s", point.x); When I use this, log output for this is: x: (null) I have verified that point is not null when this is called using the debugger and variable watch. Any help appreciated, Thanks // :)

iPhone app design storyboard vs nib

As a beginning developer I'm wondering what the pros and cons are of using Storyboard vs. .nib files to build app interfaces. I'm aware that: Storyboards supposedly streamline the process of creating interfaces Apps created with storyboards are not compatible with devices running pre-iOS 5 However, I'd like to ask people with experience what the unforeseen drawbacks or advantages may be to using one method over the other, and what experienced developers recommend starting out on. (I'll be developing both for personal and commercial use.) Thank you very much!

iOS Creating a list of tags

I'm currently trying to implement a feature in my app that shows tags for a post. I want it to work very similar to that of tags here on StackOverflow, in that they have a colored background. Another example, are the Inline Labels here . I'm just not quite sure on how to get it implemented. My first guess would to create an array of UILabels... Any suggestions?

Intermittent EXC_BAD_ACCESS exception with CATitledLayer

I am having some problems with an app that keeps crashing intermittently. Code below is in a UIView with CATiledLayer as its backing layer: - (UIBezierPath *)path { if(_path == nil){ _path = [UIBezierPath bezierPath]; CGFloat lineWidth = 5; [_path setLineWidth:lineWidth]; [_path setLineJoinStyle:kCGLineJoinRound]; [_path setLineCapStyle:kCGLineCapRound]; [_path moveToPoint:CGPointMake(100, 100)]; [_path addLineToPoint:CGPointMake(200,200)]; [_path addLineToPoint:CGPointMake(150,200)]; [_path addLineToPoint:CGPointMake(50,400)]; _path closePath]; return _path; } return _path; } - (void)drawRect:(CGRect)rect { [[UIColor colorWithRed:0.1 green:0.1 blue:1 alpha:0.45] setStroke];//sets stroke color in current context [self.path stroke]; } I get the following error code: Single stepping until exit from function _ZN2CG4Path15apply_transformERK17CGAffineTransform, which ha

ibooks like carousel view

I want to create and app with carousel kind of view, with images in rows and columns, where number of columns are fixed, but number of rows varies. when user clicks on an image it opens up a detailed view. My initial approach is to used tableview, with one cell as a row, but here tricky part is calculating the column, which I am doing by tagging the views. Is my approach is right or is there is any other better way of doing it.