I have a UIModalPresentationFullScreen but my UI elements are not showing up properly. I want to define the screensize in IB, but I'm not sure what the size should be?
Hi all,
i wonder,how can i record while playing an audio or something withing my app,
for ex
i hv a guitar app,i can play guitar withing my app,
now i hv a record button,when user pushes the click button, recoding should be started, and it should start recording,whatever the user isplaying on the guitar, within the app.
in between that,user can pause ,play or stop recoring..
after done,he must be able to play whole recoring...
any help would be appreciated.
regards
shishir
Hi,
I have a scrollview on a controller.
To enable paging for scrollview, i have added another controller, which initializes when the pages are made. That means for each page i have a controller made at run time.
In the view of scroll controller, i am trying to draw an image using drawRect.
The problem is i see the drawn image only for the 1st page and when i scroll, the other controllers are blank.
Please help
I have an app where my main view accepts both touchesBegan and touchesMoved, and therefore takes in single finger touches, and drags. I want to implement a UIScrollView, and I have it working, but it overrides the drags, and therefore my contentView never receives them. I'd like to implement a UIScrollview, where a two finger drag indicates a scroll, and a one finger drag event gets passed to my content view, so it performs normally. Do I need create my own subclass of UIScrollView?
Here's my code from my appDelegate where I implement the UIScrollView.
@implementation MusicGridAppDelegate
@synthesize window;
@synthesize viewController;
@synthesize scrollView;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
//[application setStatusBarHidden:YES animated:NO];
//[window addSubview:viewController.view];
scrollView.contentSize = CGSizeMake(720, 480);
scrollView.showsHorizontalScrollIndicator = YES;
scrollView.showsVerticalScrollIndicator = YES;
scrollView.delegate = self;
[scrollView addSubview:viewController.view];
[window makeKeyAndVisible];
}
- (void)dealloc {
[viewController release];
[scrollView release];
[window release];
[super dealloc];
}
I have a UIScrollView that contains large images and am using paging to scroll between images. In order to save memory, I am loading only one image before and after the currently visible one and loading/releasing new images after a scroll has completed.
The problem occurs when one scrolls quickly and scrollViewDidEndDecelerating is not called.
How can I detect continuous scrolling?
I could check item location on every scrollViewDidScroll but this seems a bit heavy...
I have some VERY simple code to return the title for a section header:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if (section==0) {
return @"";
} else if (section==1) {
return @"Actions";
} else if (section==2) {
return @"Attached To";
}
return @"";
}
For some reason when the headers are actually displayed on the simulator, half of the time they're simply the first letter and then ellipses. Scrolling up and down (to refresh the header view most likely) will result in the title showing correctly roughly half the time and showing incorrectly the other half of the time.
Do anyone have any idea what could be causing this? I think this is more of a recent development, but it seems to happen in almost all UITableViews in my application. I don't want to say this is a 3.2 issue, but it might have started happening around then, but either way it must be related to the code somehow. Thank you.
Hi
I have a UITableViewController where I added a "editButtonItem" in the navigation bar :
self.navigationItem.leftBarButtonItem = self.editButtonItem;
No magic here, but I try to define the color (background and foreground/textcolor) of this button.
I read in the Apple forum somewhere that the button changes the color if I change the navigationbar to the same color, well despite the fact that I do not get this to work either (for testing) I do not want to touch the navigationbr itself, just the button.
Since this button is already predefined I am not sure how to handle this. Do I need to overwrite the button with my own definition or can I just simply apply a new style (if so how ?)
Thx
Hi all, when I launch my app, I keep getting this CGContextFillEllipseInRect: invalid context error. My app is simply to make the circle 'pinchable'.
The debugger shows me this:
[Session started at 2010-05-23 18:21:25 +0800.]
2010-05-23 18:21:27.140 Erase[8045:207] I'm being redrawn.
Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context
2010-05-23 18:21:27.144 Erase[8045:207] New value of counter is 1
2010-05-23 18:21:27.144 Erase[8045:207] I'm being redrawn.
Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context
2010-05-23 18:21:27.144 Erase[8045:207] New value of counter is 2
2010-05-23 18:21:27.144 Erase[8045:207] I'm being redrawn.
Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context
2010-05-23 18:21:27.144 Erase[8045:207] New value of counter is 3
2010-05-23 18:21:27.145 Erase[8045:207] I'm being redrawn.
Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context
2010-05-23 18:21:27.145 Erase[8045:207] New value of counter is 4
2010-05-23 18:21:27.148 Erase[8045:207] I'm being redrawn.
Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context
2010-05-23 18:21:27.149 Erase[8045:207] New value of counter is 5
2010-05-23 18:21:27.150 Erase[8045:207] I'm being redrawn.
Sun May 23 18:21:27 Sidwyn-Kohs-MacBook-Pro.local Erase[8045] <Error>: CGContextFillEllipseInRect: invalid context
2010-05-23 18:21:27.150 Erase[8045:207] New value of counter is 6
My implementation file is:
//
// ImageView.m
// Erase
//
#import "ImageView.h"
#import "EraseViewController.h"
@implementation ImageView
-(void)setNewRect:(CGRect)anotherRect{
newRect = anotherRect;
}
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
newRect = CGRectMake(0,0,0,0);
ref = UIGraphicsGetCurrentContext();
}
return self;
}
- (void)drawRect:(CGRect)rect {
static int counter = 0;
CGRect veryNewRect = CGRectMake(30.0, 210.0, 60.0, 60.0);
NSLog(@"I'm being redrawn.");
if (counter == 0){
CGContextFillEllipseInRect(ref, veryNewRect);
}
else{
CGContextFillEllipseInRect(ref, rect);
}
counter++;
NSLog(@"New value of counter is %d", counter);
}
- (void)setNeedsDisplay{
[super setNeedsDisplay];
[self drawRect:newRect];
}
- (void)dealloc {
[super dealloc];
}
@end
I've got two questions:
1) Why is it updating counter 6 times? I removed the line [super setNeedsDisplay]; but it becomes 4 times.
2) What is that invalid context error?
Thanks guys.
My app starts by presenting a tableview whose datasource is a Core Data SQLite store. When the app starts, a secondary thread with its own store controller and context is created to obtain updates from the web for data in the store. However, any resulting changes to the store are not notified to the fetchedresults controller (I presume because it has its own coordinator) and consequently the table is not updated with store changes. What would be the most efficient way to refresh the context on the main thread? I am considering tracking the objectIDs of any objects changed on the secondary thread, sending those to the main thread when the secondary thread completes and invoking "[context refreshObject:....] Any help would be greatly appreciated.
Hi,
How is it possible to use a sound file (recorded by the App) as a ringtone?
Can it be used in any other way out side of the Application as well?
Thanks.
How can I popview from back button pressed, i passed the below code from previous view controller. Thanks
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]
initWithTitle:@"Back"
style:UIBarButtonItemStyleBordered
target:nil action:nil];
I have a UITableViewCell and it is UITableViewCellStyleDefault. When I try to put text longer than the UITableViewCell, it truncates it. How do I make the cell expand to accommodate this text?
I am using apple's custom table view cell code and modifying the drawRect code within the cell's view to look like I want it to. I've changed it to have some UILabels as well as a UIProgressView.
If the data the cell is being built on doesn't have a certain field, I want the UIProgressView to be hidden. This works for a little while, but when a cell gets requeued, the progress view will start displaying again, even when I set it to hidden = YES. I've tried just not creating the ProgressView unless the data was there and that didn't work either.
I thought the answer was in the [self setNeedsDisplay] but that doesn't seem to help.
Here is the code for the progressview from drawRect that continues to be displayed:
UIProgressView *c1Progress = [[UIProgressView alloc]initWithFrame:CGRectMake(20.0, 70.0, 280.0, 12.0)];
float iProgress = (value / target);
c1Progress.progress = iProgress;
if (!dataExists) {
c1Progress.hidden = YES;
}
[self addSubview:criteria1Progress];
[c1Progress release];
Hi folks
Sorry if this is an easy one. Basically, here is my code:
MainViewController.h:
//
// MainViewController.h
// Site
//
// Created by Jack Webb-Heller on 19/03/2010.
// Copyright __MyCompanyName__ 2010. All rights reserved.
//
#import "FlipsideViewController.h"
@interface MainViewController : UIViewController <UIWebViewDelegate, FlipsideViewControllerDelegate> {
IBOutlet UIWebView *webView;
IBOutlet UIActivityIndicatorView *spinner;
}
- (IBAction)showInfo;
@property(nonatomic,retain) UIWebView *webView;
@property(nonatomic,retain) UIActivityIndicatorView *spinner;
@end
MainViewController.m:
//
// MainViewController.m
// Site
//
// Created by Jack Webb-Heller on 19/03/2010.
// Copyright __MyCompanyName__ 2010. All rights reserved.
//
#import "MainViewController.h"
#import "MainView.h"
@implementation MainViewController
@synthesize webView;
@synthesize spinner;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
return self;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
NSURL *siteURL;
NSString *siteURLString;
siteURLString=[[NSString alloc] initWithString:@"http://www.site.com"];
siteURL=[[NSURL alloc] initWithString:siteURLString];
[webView loadRequest:[NSURLRequest requestWithURL:siteURL]];
[siteURL release];
[siteURLString release];
[super viewDidLoad];
}
- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller {
[self dismissModalViewControllerAnimated:YES];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[spinner stopAnimating];
spinner.hidden=FALSE;
NSLog(@"viewDidFinishLoad went through nicely");
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
[spinner startAnimating];
spinner.hidden=FALSE;
NSLog(@"viewDidStartLoad seems to be working");
}
- (IBAction)showInfo {
FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[spinner release];
[webView release];
[super dealloc];
}
@end
Unfortunately nothing is ever written to my log, and for some reason the Activity Indicator never seems to appear. What's going wrong here?
Thanks folks
Jack
I have a viewController and have added a subview in it programatically.
secondView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.view addSubview:secondView];
I guess when the device rotates, my mainViewController knows that orientation changed, but the subview (secondView) inside the mainViewController does not know this, so I change its frame to landscape size in willRotateToInterfaceOrientation.
secondView.frame = CGRectMake(0, 0, 480 , 260);
This does not set in the correct position, it's 11 px below the NavigationBar.
Why does it start from 11 px below the navigation bar?
The navigation bar shrinks when we move from portrait to landscape mode and its because of this that my subview is 11px below.
In the code below I am popping up a ImageView as the result of a users touchUpInside on a simple info button. There are other buttons on the view.
To dismiss the info I added a UITapGestureRecognizer to my controllers view, and hide the view when the tap is detected.
If I don't remove the tapGestureRecognizer, the action is called every time some.
Even when I do remove the gesture action, no bottons receive touchUpInside events once this gesture recognizer is added. Why?
Code from my MainViewController
(void) dismissInfo: (UITapGestureRecognizer *)gesture {
[kInfoView setHidden: YES];
[gesture removeTarget: self action: NULL];
}
(IBAction) displayInfo {
CGRect startFrame = CGRectMake(725, 25, 0, 0), origFrame;
CGFloat yCenter = [kInfoView frame].size.height/2 + 200;
CGPoint startCenter = CGPointMake(724, 25), displayCenter = CGPointMake(384, yCenter);
UITapGestureRecognizer *g = [[UITapGestureRecognizer alloc] initWithTarget: self
action: @selector(dismissInfo:)];
[self.view addGestureRecognizer: g];
origFrame = [kInfoView frame];
[kInfoView setCenter: startCenter];
[kInfoView setHidden: NO];
[kInfoView setFrame: startFrame];
[UIView beginAnimations: @"info" context: nil];
[UIView setAnimationDuration: .5];
[UIView setAnimationDelegate: self];
[kInfoView setFrame: origFrame];
[kInfoView setCenter: displayCenter];
[UIView commitAnimations];
}
i want to add the menu button in the document file to open it in the other app ,how to add the button in the menubar to open it in the other app.
how can i use this method for that-
(BOOL)presentOpenInMenuFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated
if anyone know pls answer the question.
I am just curious, is there a way to print via NSLog the contents of a struct?
id <MKAnnotation> mp = [annotationView annotation];
MKCoordinateRegion region =
MKCoordinateRegionMakeWithDistance([mp coordinate], 350, 350);
I am trying to output whats in [mp coordinate] for debugging.
.
EDIT_001:
I cracked it, well unless there is another way.
id <MKAnnotation> mp = [annotationView annotation];
CLLocationCoordinate2D location = [mp coordinate];
NSLog(@"LAT: %f LON: %f", location.latitude, location.longitude);
many thanks
gary
I have a query regarding how delegates work. My understanding was that delegates take responsibility for doing certain tasks on behalf of another object.
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
Am I right in thinking that in the example code above that the instance of CLLocationManager is created on a new thread so that it can get on with trying to find the location information it needs. When it completes its task (or encounters an error) it calls-back using the appropriate methods located in self e.g.
locationManager:didUpdateToLocation:fromLocation:
Essentially locationManager sends messages to self (which conforms to the correct delegate protocol) when things happen
cheers gary
Hi,
I'm doing something with UIImagePickerController.
It works fine and the Picture browser does open, however, I get this message. "Failed to save the videos metadata to the filesystem. Maybe the information did not conform to a plist."
What could be causing that? That is caused by this line [self presentModalViewController:self.imgPicker animated:YES]; which is activated on a button click
Snippets of the code that I have below.
- (void)viewDidLoad {
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsImageEditing = YES;
self.imgPicker.delegate = self;
}
- (IBAction)grabImage {
[self presentModalViewController:self.imgPicker animated:YES];
}
it's also removing images from documents directory and from resources folder. I can not understand why? does someone found the solution to this?
Hi everybody,
I'm trying to use the migration feature in CoreData. I've followed the Apple Documentation. I have a problem in the following method:
/**
Returns the managed object model for the application.
If the model doesn't already exist, it is created by merging all of the models found in the application bundle.
*/
- (NSManagedObjectModel *)managedObjectModel {
if (managedObjectModel != nil) {
return managedObjectModel;
}
/*
* NSInvalidArgumentException', reason: '*** -[NSCFArray insertObject:atIndex:]: attempt to insert nil'
* 2010-02-17 16:27:15.338 Patrimoine[3037:207]
*/
managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];
return managedObjectModel;
}
It appears that there is the same problem on http://iphonedevelopment.blogspot.com/2009/09/core-data-migration-problems.html
Yet I did choose the method Apple suggests, by using the menu option "Add Model Version".
Do you have any idea?
I have created a UIMenuController and have set it a custom menu item like so:
UIMenuController *menuController = [UIMenuController sharedMenuController];
UIMenuItem *item1 = [[UIMenuItem alloc] initWithTitle:@"Do This" action:@selector(item1)];
[menuController setMenuItems:[NSArray arrayWithObject:item1]];
But I wanted that object to be the only one to appear so I added this code:
- (BOOL)canPerformAction: (SEL)action withSender: (id)sender {
BOOL answer = NO;
if (action == @selector(item1))
answer = YES;
return answer;
}
The problem is it still shows other## Heading ## items, such as "Select", "Select All" and "Paste".
This may have something to do with this being displayed in a UITextView.
But how do I stop if from displaying all other items?
I got an exception:
this class is not key value coding-compliant for the key textField.'
the exception occurs at this line:
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"cell" owner:?? options:nil];
What should be the owner if the class called cell.m owns this cell.xib?
I have a subview that when double tapped a protocol method on the subview's parent view controller is called like this...
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *theTouch = [touches anyObject];
if (theTouch.tapCount == 1) {
} else if (theTouch.tapCount == 2) {
if ([self.delegate respondsToSelector:@selector(editEvent:)]) {
[self.delegate editEvent:dictionary];
}
}
}
Here is the protocol method with the dictionary consuming code removed...
- (void)editEvent:(NSDictionary){
EventEditViewController *eventEditViewController =
[[EventEditViewController alloc]
initWithNibName:@"EventEditViewController" bundle:nil];
eventEditViewController.delegate = self;
navigationController = [[UINavigationController alloc]
initWithRootViewController:eventEditViewController];
[self presentModalViewController:navigationController animated:YES];
[eventEditViewController release];
}
The protocol method is called and runs without any errors but the modal view does not present itself.
I temporarily copied the protocol method's code to an IBAction method for one of the parent's view button's to isolate it from the subview. When I tap this button the modal view works fine.
Can anyone tell me what I am doing wrong? Why does it work when executed from a button on the parent view, and not from a protocol method called from a subview.
Here is what I have tried so far to work around the problem...
Restarted xCode and the simulator
Ran on the device (iTouch)
Presenting eventEditViewController instead of navigationController
Using Push instead of presentModal.
delaying the call to the protocol with performSelector directly to the protocol, to another method in the subview which calls the protocol method, from the protocol method to another method with the presentModal calls.
Using a timer.
I have it currently setup so that the protocol method calls a known working method that presents a different view. Before calling presentModalViewController it pops a UIAlertView which works every time, but the modal view refuses to display when called via the protocol method.
I'm stumped. Perhaps it has something to do with the fact that I am calling the protocol method from a UIView class instead of a UIViewController class. Maybe I need to create a UIViewController for the subView??
Thanks,
John