Search Results

Search found 19072 results on 763 pages for 'iphone sdk 4'.

Page 150/763 | < Previous Page | 146 147 148 149 150 151 152 153 154 155 156 157  | Next Page >

  • iphone navigation

    - by Rona
    function handleClickEvent(event) { var linkFrom = $(event.target); if (typeof linkFrom.attr("href") == 'undefined') { linkFrom = $(event.target).parent(); } var targetPage = linkFrom.attr("href"); if (linkFrom.hasClass('submit')) { handleSubmitEvent(event); // if we want to stop processing: return false; } if (linkFrom.hasClass('backbutton')) { targetPage = historyStack.pop(); if (historyStack.length == 0) { lastPage = "index.html"; } } else { historyStack.push(lastPage); } lastPage = targetPage; $(event.target).css({ 'background-color': '#194fdb', 'color': '#ffffff' }); loadingWindowON(); // Add new unique div prevPageId = "page" + pageIdCounter; pageIdCounter = parseInt(pageIdCounter) + 1 nextPageId = "page" + pageIdCounter; nextPageDiv = "<div id='" + nextPageId + "' class='nextpage' /></div>"; $("body").append(nextPageDiv); if (linkFrom.attr("target") != "_blank") { event.preventDefault(); document.getElementById(nextPageId).addEventListener('webkitAnimationEnd', function () { // remove prev div element = document.getElementById(prevPageId); if (element) { element.parentNode.removeChild(element); } // set next div as current document.getElementById(nextPageId).className = 'currentpage'; }, false); document.getElementById(nextPageId).className += ' slideleftIn'; document.getElementById(prevPageId).className += ' slideleftOut'; loadContent(targetPage, nextPageId); } I use this javascript with a twitter app I had to do and when I click a button, instead of sliding the new page from the side it adds it to the existing page at the bottom. It works fine when i open it on my computer using google chrome but when I try to open it with my iphone it doesn't work. Any ideas?

    Read the article

  • iPhone Development: Use POST to submit a form

    - by Mario
    I've got the following html form: <form method="post" action="http://shk.ecomd.de/up.php" enctype="multipart/form-data"> <input type="hidden" name="id" value="12345" /> <input type="file" name="pic" /> <input type="submit" /> </form> And the following iPhone SDK Submit method: - (void)sendfile { UIImage *tempImage = [UIImage imageNamed:@"image.jpg"]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setHTTPMethod:@"POST"]; [request setURL:[NSURL URLWithString:@"http://url..../form.php"]]; NSString *boundary = @"------------0xKhTmLbOuNdArY"; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary]; [request addValue:contentType forHTTPHeaderField: @"Content-Type"]; NSMutableData *body = [NSMutableData data]; [body appendData:[[NSString stringWithFormat:@"\r\n%@\r\n",boundary] dataUsingEncoding:NSASCIIStringEncoding]]; [body appendData:[@"Content-Disposition: form-data; name=\"id\"\r\n\r\n" dataUsingEncoding:NSASCIIStringEncoding]]; [body appendData:[@"12345" dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"\r\n%@\r\n",boundary] dataUsingEncoding:NSASCIIStringEncoding]]; [body appendData:[@"Content-Disposition: form-data; name=\"pic\"; filename=\"photo.png\"\r\n" dataUsingEncoding:NSASCIIStringEncoding]]; [body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSASCIIStringEncoding]]; [body appendData:[NSData dataWithData:UIImageJPEGRepresentation(tempImage, 90)]]; [body appendData:[[NSString stringWithFormat:@"\r\n%@",boundary] dataUsingEncoding:NSASCIIStringEncoding]]; // setting the body of the post to the reqeust [request setHTTPBody:body]; NSError *error; NSURLResponse *response; NSData* result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSString* aStr = [[[NSString alloc] initWithData:result encoding:NSASCIIStringEncoding] autorelease]; NSLog(@"Result: %@", aStr); [request release]; } This does not work, but I have no clue why. Can you please help me?!! What am I doing wrong?

    Read the article

  • Retrieving a list of eBay categories using the .NET SDK and GetCategoriesCall

    - by Bill Osuch
    eBay offers a .Net SDK for its Trading API - this post will show you the basics of making an API call and retrieving a list of current categories. You'll need the category ID(s) for any apps that post or search eBay. To start, download the latest SDK from https://www.x.com/developers/ebay/documentation-tools/sdks/dotnet and create a new console app project. Add a reference to the eBay.Service DLL, and a few using statements: using eBay.Service.Call; using eBay.Service.Core.Sdk; using eBay.Service.Core.Soap; I'm assuming at this point you've already joined the eBay Developer Network and gotten your app IDs and user tokens. If not: Join the developer program Generate tokens Next, add an app.config file that looks like this: <?xml version="1.0"?> <configuration>   <appSettings>     <add key="Environment.ApiServerUrl" value="https://api.ebay.com/wsapi"/>     <add key="UserAccount.ApiToken" value="YourBigLongToken"/>   </appSettings> </configuration> And then add the code to get the xml list of categories: ApiContext apiContext = GetApiContext(); GetCategoriesCall apiCall = new GetCategoriesCall(apiContext); apiCall.CategorySiteID = "0"; //Leave this commented out to retrieve all category levels (all the way down): //apiCall.LevelLimit = 4; //Uncomment this to begin at a specific parent category: //StringCollection parentCategories = new StringCollection(); //parentCategories.Add("63"); //apiCall.CategoryParent = parentCategories; apiCall.DetailLevelList.Add(DetailLevelCodeType.ReturnAll); CategoryTypeCollection cats = apiCall.GetCategories(); using (StreamWriter outfile = new StreamWriter(@"C:\Temp\EbayCategories.xml")) {    outfile.Write(apiCall.SoapResponse); } GetApiContext() (provided in the sample apps in the SDK) is required for any call:         static ApiContext GetApiContext()         {             //apiContext is a singleton,             //to avoid duplicate configuration reading             if (apiContext != null)             {                 return apiContext;             }             else             {                 apiContext = new ApiContext();                 //set Api Server Url                 apiContext.SoapApiServerUrl = ConfigurationManager.AppSettings["Environment.ApiServerUrl"];                 //set Api Token to access eBay Api Server                 ApiCredential apiCredential = new ApiCredential();                 apiCredential.eBayToken = ConfigurationManager.AppSettings["UserAccount.ApiToken"];                 apiContext.ApiCredential = apiCredential;                 //set eBay Site target to US                 apiContext.Site = SiteCodeType.US;                 return apiContext;             }         } Running this will give you a large (4 or 5 megs) XML file that looks something like this: <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">    <soapenv:Body>       <GetCategoriesResponse >          <Timestamp>2012-06-06T16:03:46.158Z</Timestamp>          <Ack>Success</Ack>          <CorrelationID>d02dd9e3-295a-4268-9ea5-554eeb2e0e18</CorrelationID>          <Version>775</Version>          <Build>E775_CORE_BUNDLED_14891042_R1</Build> -          <CategoryArray>             <Category>                <BestOfferEnabled>true</BestOfferEnabled>                <AutoPayEnabled>true</AutoPayEnabled>                <CategoryID>20081</CategoryID>                <CategoryLevel>1</CategoryLevel>                <CategoryName>Antiques</CategoryName>                <CategoryParentID>20081</CategoryParentID>             </Category>             <Category>                <BestOfferEnabled>true</BestOfferEnabled>                <AutoPayEnabled>true</AutoPayEnabled>                <CategoryID>37903</CategoryID>                <CategoryLevel>2</CategoryLevel>                <CategoryName>Antiquities</CategoryName>                <CategoryParentID>20081</CategoryParentID>             </Category> (etc.) You could work with this, but I wanted a nicely nested view, like this: <CategoryArray>    <Category Name='Antiques' ID='20081' Level='1'>       <Category Name='Antiquities' ID='37903' Level='2'/> </CategoryArray> ...so I transformed the xml: private void TransformXML(CategoryTypeCollection cats)         {             XmlElement topLevelElement = null;             XmlElement childLevelElement = null;             XmlNode parentNode = null;             string categoryString = "";             XmlDocument returnDoc = new XmlDocument();             XmlElement root = returnDoc.CreateElement("CategoryArray");             returnDoc.AppendChild(root);             XmlNode rootNode = returnDoc.SelectSingleNode("/CategoryArray");             //Loop through CategoryTypeCollection             foreach (CategoryType category in cats)             {                 if (category.CategoryLevel == 1)                 {                     //Top-level category, so we know we can just add it                     topLevelElement = returnDoc.CreateElement("Category");                     topLevelElement.SetAttribute("Name", category.CategoryName);                     topLevelElement.SetAttribute("ID", category.CategoryID);                     rootNode.AppendChild(topLevelElement);                 }                 else                 {                     // Level number will determine how many Category nodes we are deep                     categoryString = "";                     for (int x = 1; x < category.CategoryLevel; x++)                     {                         categoryString += "/Category";                     }                     parentNode = returnDoc.SelectSingleNode("/CategoryArray" + categoryString + "[@ID='" + category.CategoryParentID[0] + "']");                     childLevelElement = returnDoc.CreateElement("Category");                     childLevelElement.SetAttribute("Name", category.CategoryName);                     childLevelElement.SetAttribute("ID", category.CategoryID);                     parentNode.AppendChild(childLevelElement);                 }             }             returnDoc.Save(@"C:\Temp\EbayCategories-Modified.xml");         } Yes, there are probably much cleaner ways of dealing with it, but I'm not an xml expert… Keep in mind, eBay categories do not change on a regular basis, so you should be able to cache this data (either in a file or database) for some time. The xml returns a CategoryVersion node that you can use to determine if the category list has changed. Technorati Tags: Csharp, eBay

    Read the article

  • Getting "Using two-stage rotation animation" warning with UIImagePickerController

    - by Kay
    Hi, I wrote simple code to test UIImagePickerController: @implementation ProfileEditViewController - (void)viewDidLoad { [super viewDidLoad]; photoTaker_ = [[UIImagePickerController alloc] init]; photoTaker_.delegate = self; photoTaker_.sourceType = UIImagePickerControllerSourceTypeCamera; photoTaker_.showsCameraControls = NO; } - (void)viewDidAppear: (BOOL)animated { [self presentModalViewController: photoTaker_ animated: NO]; } @end And I'm getting strange warnings like the following: 2010-05-20 17:53:13.838 TestProj[2814:307] Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations. 2010-05-20 17:53:13.849 TestProj[2814:307] Using two-stage rotation animation is not supported when rotating more than one view controller or view controllers not the window delegate Got any idea what this is about? Thanks a lot in advance!

    Read the article

  • Core Data managed object context thread synchronisation

    - by Ben Reeves
    I'm have an issue where i'm updating a many-to-many relationship in a background thread, which works fine in that threa, but when I send the object back to the main thread the changes do not show. If I close the app and reopen the data is saved fine and the changes show on the main thread. Also using [context lock] instead of a different managed object context works fine. I have tried NSManagedObjectContext: - (BOOL)save:(NSError **)error; - (void)refreshObject:(NSManagedObject *)object mergeChanges:(BOOL)flag; at different stages throughout the process but it doesn't seem to help. My core data code uses the following getter to ensure any operations are thread safe: - (NSManagedObjectContext *) managedObjectContext { NSThread * thisThread = [NSThread currentThread]; if (thisThread == [NSThread mainThread]) { //Main thread just return default context return managedObjectContext; } else { //Thread safe trickery NSManagedObjectContext * threadManagedObjectContext = [[thisThread threadDictionary] objectForKey:CONTEXT_KEY]; if (threadManagedObjectContext == nil) { threadManagedObjectContext = [[[NSManagedObjectContext alloc] init] autorelease]; [threadManagedObjectContext setPersistentStoreCoordinator: [self persistentStoreCoordinator]]; [[thisThread threadDictionary] setObject:threadManagedObjectContext forKey:CONTEXT_KEY]; } return threadManagedObjectContext; } } and when I pass object between threads i'm using -(NSManagedObject*)makeSafe:(NSManagedObject*)object { if ([object managedObjectContext] != [self managedObjectContext]) { NSError * error = nil; object = [[self managedObjectContext] existingObjectWithID:[object objectID] error:&error]; if (error) { NSLog(@"Error makeSafe: %@", error); } } return object; } Any help appreciated

    Read the article

  • ListView setOnItemClickListener and setOnItemSelectedListener to store the Selected Item Index

    - by Christophe
    Hi all, I have read on this site that it is necessary to customize the setOnItemSelectedListener and setOnItemClickListener of a ListView if we want to know the Index of the SelectedItem (.getSelectedItemPosition()). So that is what I do but it does not stores the position of the SekectedItem, instead i have always -1... What I want to do is just to give the user a way to delete items from a list by selected and Item and Clicking a button. See the code below : listViewPeople.setOnItemClickListener(new ListView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int i, long l) { try { // Remembers the selected Index listViewPeopleId = listViewPeople.getSelectedItemPosition(); } catch(Exception e) { System.out.println("Nay, cannot get the selected index"); } } }); listViewPeople.setOnItemSelectedListener(new ListView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> a, View v, int i, long l) { try { // Remembers the selected Index listViewPeopleId = listViewPeople.getSelectedItemPosition(); System.out.println("Yay, set the selected index " + listViewPeopleId); } catch(Exception e) { System.out.println("Nay, cannot get the selected index " + listViewPeopleId); } } @Override public void onNothingSelected(AdapterView<?> arg0) { try { // Remembers nothing selected listViewPeopleId = -1; System.out.println("Yay, set that nothing is selected " + listViewPeopleId); } catch(Exception e) { System.out.println("Nay, cannot set that nothing is selected " + listViewPeopleId); } } }); What's wrong?? Thank you for your help! Christophe

    Read the article

  • How to create a smooth CATransition effect

    - by Futur
    The CATransition what i have implemented works really fine but not smooth, i could see the previous uiview screens during the transition, I am just doing this, CATransition *animation = [CATransition animation]; [animation setDuration:0.1]; [animation setType:kCATransitionPush]; [animation setSubtype:kCATransitionFromRight]; [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; [[objView layer] addAnimation:animation forKey:@"SwitchToView"]; For moving forward and for moving back wards, CATransition *animation = [CATransition animation]; [animation setDuration:0.1]; [animation setType:kCATransitionPush]; [animation setSubtype:kCATransitionFromLeft]; [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; [[objRemovableView layer] addAnimation:animation forKey:@"SwitchToView"]; The effect of sliding is not smooth, is there any other way we can do this which works very smooth? Please help

    Read the article

  • How to display custom view in UIActionSheet?

    - by 4thSpace
    I have a UIView with a date picker that I'd like to display in an action sheet. I'm using the following code: -(IBAction) button_click:(id)sender{ //UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"the title" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Destructive" otherButtonTitles:@"other", nil]; UIActionSheet *sheet = [[UIActionSheet alloc] init]; ActionSheetController *actionSheet = [[ActionSheetController alloc] initWithNibName:@"ActionSheetView" bundle:nil]; [sheet addSubview:actionSheet.view]; [sheet showInView:self.view]; } What I get is a little bit of the top part of the new view coming up from the bottom and that's it. If I comment the two middle lines of code and uncomment the top part to display a regular action sheet, it works fine. Any ideas what I might be doing wrong?

    Read the article

  • UITableViewCell with custom gradient background, with another gradient as highlight color

    - by Rich
    I have a custom UITableViewCell with a custom layout. I wanted a gradient background, so in my UITableViewDelegate cellForRowAtIndexPath: method, I create a CAGradientLayer and add it to the cell's layer with insertSubLayer:atIndex: (using index 0). This works just fine except for two things: Most importantly, I can't figure out how to change to a different gradient color when the row is highlighted. I have tried a couple things, but I'm just not familiar enough with the framework to get it working. Where would be the ideal place to put that code, inside the table delegate or the cell itself? Also, there's a 1px white space in between each cell in the table. I have a background color on the main view, a background color on the table, and a background color on the cell. Is there some kind of padding or spacer by default in a UITableView?

    Read the article

  • Refresh MKAnnotationView on a MKMapView

    - by Konstantin
    I'd like to a-synchronically load images for my custom MKAnnotationView; I'm already using the EGOImageView-framework (it goes very well with UITableViews), but I fail to make it work on MKMapView. Images seem to be loaded, but I cannot refresh them on the map - [myMap setNeedsDisplay] does nothing.

    Read the article

  • iPad: SplitView does not rotate

    - by raj.tiwari
    I have the following setup: A subclass of UISplitViewController that creates the master and detail view controllers in the constructor. Master and Detail view controllers that both override shouldAutorotateToInterfaceOrientation to return `YES'. Detail view controller implements the UISplitViewControllerDelegate protocol and deals with the popover. I am observing two weird issues that might be interrelated: When the split view comes up (in portrait mode - default on simulator), the Master view is visible. It should not be. When I rotate the simulator, the view does not "right" itself. My UISplitViewController subclass does not override shouldAutorotateToInterfaceOrientation. However, both master and details view controllers do and return YES. Any ideas what I might be doing wrong? Is this a simulator bug? Thanks. -Raj

    Read the article

  • Showing Master/Detail UITableView inside UIPopOverController

    - by tilomitra
    I have a UIPopOverController that shows a UIViewController with a UITableview in its view. The cells in the table have a detailedView, but whenever that view gets pushed, the PopOverController increases in size, and I am left with all this white space inside it. Question is this: Can anyone show me how I can have a Master/Detail UITableview show inside a PopOverController whilst preserving its dimensions? Some of my code if it helps you: //Creating the PopOver with the UIViewController addTaskViewController = [[AddTaskViewController alloc] initWithNibName:@"AddTaskViewController" bundle:nil]; UINavigationController *addTaskNavController = [[UINavigationController alloc] initWithRootViewController:addTaskViewController]; UIPopoverController *addTaskPopOver = [[UIPopoverController alloc] initWithContentViewController:addTaskNavController]; self.addTaskPopOverController = addTaskPopOver; addTaskPopOverController.delegate = self; //...neccessary releases... //Showing the popover when a button is pressed - (void) addTasksButtonPressed:(id)sender { //Display the Popover containing a view from AddTaskViewController [self.addTaskPopOverController setPopoverContentSize:CGSizeMake(400, 700)]; [addTaskPopOverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES]; }

    Read the article

  • Xcode strange warning - Multiple build commands for output file

    - by Futur
    Hi All, I am getting an error like this, [WARN]Warning: Multiple build commands for output file /Developer/B/Be/build/Release-iphonesimulator/BB.app/no.png [WARN]Warning: Multiple build commands for output file /Developer/B/Be/build/Release-iphonesimulator/BB.app/d.png [WARN]Warning: Multiple build commands for output file /Developer/B/Be/build/Release-iphonesimulator/BB.app/n.png but i have checked the xcode and i dont see any duplicates of such files at all. As the apple lists says : http://lists.apple.com/archives/xcode-users/2006/Dec/msg00276.html there are no duplicates. Please help.

    Read the article

  • How do I scale a UIButton's imageView?

    - by vcLwei
    Hey guys! I create a UIButton instance(named "button") with a image use [UIButton setImage:forState:] function, the button.frame is larger than the image's size. Now I want to scale this button's image smaller. I had tried to change button.imageView.frame, button.imageView.bounds and button.imageView.contentMode, but all seem ineffective. Hopefully someone can help me how to scale a UIButton's imageView.Thanks! my create UIButton instance code: UIButton *button = [[UIButton alloc] init]; [button setImage:image forState:UIControlStateNormal]; my try to scale the image code: button.imageView.contentMode = UIViewContentModeScaleAspectFit; button.imageView.bounds = CGRectMake(0, 0, 70, 70); and: button.imageView.contentMode = UIViewContentModeScaleAspectFit; button.imageView.frame = CGRectMake(0, 0, 70, 70);

    Read the article

  • Save image to camera roll with UIImageWriteToSavedPhotosAlbum

    - by Momeks
    Hi , i try to save a photo with a button to camera roll after user capture a picture with Camera , but i dont know why my picture doesn't save at photo library !! here is my code : -(IBAction)savePhoto{ UIImageWriteToSavedPhotosAlbum(img.image,nil, nil, nil); } -(IBAction)takePic { ipc = [[UIImagePickerController alloc]init]; ipc.delegate = self; ipc.sourceType = UIImagePickerControllerSourceTypeCamera; [self presentModalViewController:ipc animated:YES]; } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { img.image = [[info objectForKey:UIImagePickerControllerOriginalImage]retain]; [[picker parentViewController]dismissModalViewControllerAnimated:YES]; [picker release]; } ipc is UIImagePickerController and img is UIIMageView what's my problem ?

    Read the article

  • dyld: Library not loaded: /System/Library/Frameworks/UIKit.framework/UIKit

    - by jimbo
    Hi All, Please bear with me, newbie just learning the ropes. I am getting the below message, when I try and run my app, it quiets, but then does let me re-open fine after the first quit. I tried a few things and if I turn on if i 'activate breakpoints' it all works fine... Tried a few suggestions, 'deleting build folder', 'restarting xCode' nothing seems to work... dyld: Library not loaded: /System/Library/Frameworks/UIKit.framework/UIKit Referenced from: /Volumes/MyBook/Apps/CToolBox/build/Debug-iphonesimulator/CToolBox.app/CToolBox Reason: image not found The Debugger has exited due to signal 5 (SIGTRAP).The Debugger has exited due to signal 5 (SIGTRAP). Thanks in advance.

    Read the article

  • Optimized Image Loading in a UIScrollView

    - by Michael Gaylord
    I have a UIScrollView that has a set of images loaded side-by-side inside it. You can see an example of my app here: http://www.42restaurants.com. My problem comes in with memory usage. I want to lazy load the images as they are about to appear on the screen and unload images that aren't on screen. As you can see in the code I work out at a minimum which image I need to load and then assign the loading portion to an NSOperation and place it on an NSOperationQueue. Everything works great apart from a jerky scrolling experience. I don't know if anyone has any ideas as to how I can make this even more optimized, so that the loading time of each image is minimized or so that the scrolling is less jerky. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ [self manageThumbs]; } - (void) manageThumbs{ int centerIndex = [self centerThumbIndex]; if(lastCenterIndex == centerIndex){ return; } if(centerIndex >= totalThumbs){ return; } NSRange unloadRange; NSRange loadRange; int totalChange = lastCenterIndex - centerIndex; if(totalChange > 0){ //scrolling backwards loadRange.length = fabsf(totalChange); loadRange.location = centerIndex - 5; unloadRange.length = fabsf(totalChange); unloadRange.location = centerIndex + 6; }else if(totalChange < 0){ //scrolling forwards unloadRange.length = fabsf(totalChange); unloadRange.location = centerIndex - 6; loadRange.length = fabsf(totalChange); loadRange.location = centerIndex + 5; } [self unloadImages:unloadRange]; [self loadImages:loadRange]; lastCenterIndex = centerIndex; return; } - (void) unloadImages:(NSRange)range{ UIScrollView *scrollView = (UIScrollView *)[[self.view subviews] objectAtIndex:0]; for(int i = 0; i < range.length && range.location + i < [scrollView.subviews count]; i++){ UIView *subview = [scrollView.subviews objectAtIndex:(range.location + i)]; if(subview != nil && [subview isKindOfClass:[ThumbnailView class]]){ ThumbnailView *thumbView = (ThumbnailView *)subview; if(thumbView.loaded){ UnloadImageOperation *unloadOperation = [[UnloadImageOperation alloc] initWithOperableImage:thumbView]; [queue addOperation:unloadOperation]; [unloadOperation release]; } } } } - (void) loadImages:(NSRange)range{ UIScrollView *scrollView = (UIScrollView *)[[self.view subviews] objectAtIndex:0]; for(int i = 0; i < range.length && range.location + i < [scrollView.subviews count]; i++){ UIView *subview = [scrollView.subviews objectAtIndex:(range.location + i)]; if(subview != nil && [subview isKindOfClass:[ThumbnailView class]]){ ThumbnailView *thumbView = (ThumbnailView *)subview; if(!thumbView.loaded){ LoadImageOperation *loadOperation = [[LoadImageOperation alloc] initWithOperableImage:thumbView]; [queue addOperation:loadOperation]; [loadOperation release]; } } } } EDIT: Thanks for the really great responses. Here is my NSOperation code and ThumbnailView code. I tried a couple of things over the weekend but I only managed to improve performance by suspending the operation queue during scrolling and resuming it when scrolling is finished. Here are my code snippets: //In the init method queue = [[NSOperationQueue alloc] init]; [queue setMaxConcurrentOperationCount:4]; //In the thumbnail view the loadImage and unloadImage methods - (void) loadImage{ if(!loaded){ NSString *filename = [NSString stringWithFormat:@"%03d-cover-front", recipe.identifier, recipe.identifier]; NSString *directory = [NSString stringWithFormat:@"RestaurantContent/%03d", recipe.identifier]; NSString *path = [[NSBundle mainBundle] pathForResource:filename ofType:@"png" inDirectory:directory]; UIImage *image = [UIImage imageWithContentsOfFile:path]; imageView = [[ImageView alloc] initWithImage:image andFrame:CGRectMake(0.0f, 0.0f, 176.0f, 262.0f)]; [self addSubview:imageView]; [self sendSubviewToBack:imageView]; [imageView release]; loaded = YES; } } - (void) unloadImage{ if(loaded){ [imageView removeFromSuperview]; imageView = nil; loaded = NO; } } Then my load and unload operations: - (id) initWithOperableImage:(id<OperableImage>) anOperableImage{ self = [super init]; if (self != nil) { self.image = anOperableImage; } return self; } //This is the main method in the load image operation - (void)main { [image loadImage]; } //This is the main method in the unload image operation - (void)main { [image unloadImage]; }

    Read the article

  • SQLite Step Failed: attempt to write a readonly database , using wrapper

    - by user271753
    I keep getting an error "SQLite Step Failed: attempt to write a readonly database" when using this code to copy a database: -(void)createEditableCopyOfDatabaseIfNeeded { // Testing for existence BOOL success; NSFileManager *fileManager = [NSFileManager defaultManager]; NSError *error; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"Money.sqlite"]; success = [fileManager fileExistsAtPath:writableDBPath]; if (success) return; // The writable database does not exist, so copy the default to // the appropriate location. NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Money.sqlite"]; success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error]; if(!success) { NSAssert1(0,@"Failed to create writable database file with Message : '%@'.", [error localizedDescription]); } } I am using the above code in AppDelegate and this: NSString *writableDBPath = [[NSBundle mainBundle] pathForResource:@"Money" ofType:@"sqlite"]; In ViewController.m I am using http://th30z.netsons.org/2008/11/objective-c-sqlite-wrapper/ what am I doing wrong? This is happening again and again... It was working fine before but again the problem started.

    Read the article

  • UISplitViewController and complex view heirarchy

    - by Jasconius
    I'm doing an iPad tech demo and I'm running into a serious technical problem. I have an app concept that leverages UISplitViewController, but NOT as the primary controller for the entire app. The app flow could be described roughly as this: Home screen (UIViewController) List-Detail "Catalog" (UISplitViewController) Super Detail Screen (UIViewController but could conceivable also be a child of SplitView). The problem is in the flow between Home and Catalog. Once a UISplitViewController view is added to the UIWindow, it starts to throw hissy fits. The problem can be summarized at this: When a UISplitView generates a popover view, it appears to then be latched to its parent view. Upon removing the UISplitView from the UIWindow subviews, you will get a CoreGraphics exception and the view will fail to be removed. When adding other views (presumably in this case, the home screen to which you are returning), they do not autorotate, instead, the UISplitView, which has failed to be removed due to a CG exception, continues to respond to the rotation instead, causing horrible rendering bugs that can't be just "dealt with". At this point, adding any views, even re-adding the SplitView, causes a cascade of render bugs. I then tried simply to leave the SplitView ever present as the "bottom" view, and keeping adding and removing the Home Screen from on top of it, but this fails as SplitView dominates the Orientation change calls, and Home Screen will not rotate, even if you call [homeScreen becomeFirstResponder] You can't put SplitView into a hierarchy like UINavigationController, you will get an outright runtime error, so that option is off the table. Modals just look bad and are discourages anyway. My presumption at this moment is that the only proper way to deal with this problem is so somehow "disarm" UISplitViewController so that it can be removed from its parent view without throwing an unhandled exception, but I have no idea how. If you want to see an app that does exactly what I need to do, check out GILT Groupe in the iPad app store. They pulled it off, but they seem to have programmed an entire custom view transition set. Help would be greatly appreciated.

    Read the article

  • Resizing an image with stretchableImageWithLeftCapWidth

    - by Stephan Burlot
    I'm trying to resize an image using stretchableImageWithLeftCapWidth: it works on the simulator, but on the device, vertical green bars appears. I've tried to use imageNamed, imageWithContentOfFile and imageWithData lo load the image, it doesnt change. UIImage *bottomImage = [[UIImage imageWithData: [NSData dataWithContentsOfFile: [NSString stringWithFormat:@"%@/bottom_part.png", [[NSBundle mainBundle] resourcePath]]]] stretchableImageWithLeftCapWidth:27 topCapHeight:9]; UIImageView *bottomView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 200+73, 100, 73)]; [self.view addSubview:bottomView]; UIGraphicsBeginImageContext(CGSizeMake(100, 73)); [bottomImage drawInRect:CGRectMake(0, 0, 100, 73)]; UIImage *bottomResizedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); bottomView.image = bottomResizedImage; See the result: the green bars shouldn't be there, they dont appear on the simulator.

    Read the article

  • Sorting a multidimensional array in objective-c

    - by Zen_silence
    Hello, I'm trying to sort a multidimensional array in objective-c i know that i can sort a single dimensional array using the line of code below: NSArray *sortedArray = [someArray sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; I can't seem to figure out how to sort a 2D array like the one below: ( ("SOME_URL", "SOME_STORY_TITLE", "SOME_CATEGORY"), ("SOME_URL", "SOME_STORY_TITLE", "SOME_CATEGORY"), ("SOME_URL", "SOME_STORY_TITLE", "SOME_CATEGORY") ); If someone could provide me code that would sort the array by SOME_CATEGORY it would be of great help to me. Thanks, Zen_Silence

    Read the article

  • overridden three20 TTDefaultStyleSheet style not working

    - by funkadelic
    hi, i recently got three20 integrated into my app and am trying to override the default toolbar color in TTWebController. In TTWebController.m:118 I see that this is setting the toolbar's tintColor: _toolbar.tintColor = TTSTYLEVAR(toolbarTintColor); So I created my own stylesheet that subclasses TTDefaultStyleSheet and overrides toolbarTintColor FooStyleSheet.h: #import <Three20Style/Three20Style.h> #import <Three20Style/TTStyleSheet.h> #import <Three20Style/TTDefaultStyleSheet.h> @interface FooStyleSheet : TTDefaultStyleSheet @property (nonatomic, readonly) UIColor* toolbarTintColor; @end FooStyleSheet.m: #import "FooStyleSheet.h" @implementation RaptrStyleSheet - (UIColor*)toolbarTintColor { return RGBCOLOR(0, 0, 0); // should override TTDefaultStyleSheet } @end and in my application:didFinishLaunchingWithOptions: i set my default stylesheet [TTStyleSheet setGlobalStyleSheet:[[[FooStyleSheet alloc] init] autorelease]]; but when I view the TTWebController, it doesn't inherit my tintColor. If I edit TTDefaultStyleSheet.m directly: - (UIColor*)toolbarTintColor { return [UIColor blackColor]; } it works as expected. Is there something I am overlooking that is preventing my style to be picked up? thanks, -norm

    Read the article

  • Initial selected Item in an UITabBar without a UITabBarController

    - by juan.xavier
    Hello, How do I set the default selected UITabBarItem in an UITabBar that is within an UIView, not an UITabBarController? Just to clarify, the UIView does implement the protocol and the didSelectItem method works. At run-time, the tabbar works and the tabbaritems selected when the user touches them. My problem is setting the default selected item. If i use [myTabbar setSelectedItem] within the didSelectItem method it works. But outside of it, it doesn't (for example, in the viewDidLoad method of my UIView). Thanks!

    Read the article

  • How do I zoom an MKMapView to the users current location without CLLocationManager?

    - by Danny Tuppeny
    With the MKMapView there's an option called "Show users current location" which will automatically show a users location on the map. I'd like to zoom into this location without adding a CLLocationManager (this seems silly if the map is already taking care of this). The problem is, I can't find a nice event that fires when the map has figured out the users location, so I don't know where to put the code that will zoom/scroll. I tried using the viewForAnnotation method like this: - (MKAnnotationView *) mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation { if ([annotation class] == [MKUserLocation class] ) { NSLog(@"UserLocation annotation"); return [map viewForAnnotation:annotation]; } return nil; } However it doesn't fire if the users location is off the screen. Is there a way to be notified when an MKMapView has got the user location so I can zoom in to it, or do I just have to add a CLLocationManager for this?

    Read the article

< Previous Page | 146 147 148 149 150 151 152 153 154 155 156 157  | Next Page >