Search Results

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

Page 153/763 | < Previous Page | 149 150 151 152 153 154 155 156 157 158 159 160  | Next Page >

  • Custom UITableViewCell won't redraw on setNeedsDisplay

    - by Andrew Portner
    I created a custom UITableViewCell class with a UIButton, a UIImage, and two UILabels. The button and the image are overlayed on top of each other, and only one is displayed at a time. The expected behavior is you touch on the button, the button disappears, and it displays the image. The UITableViewCells are set to be reused. Here's my code: Constructor: - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { unheartButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; unheartButton.backgroundColor = [UIColor clearColor]; unheartButton.frame = CGRectMake(10, 13, 20, 18); [unheartButton addTarget:self action:@selector(onButtonClick:) forControlEvents:UIControlEventTouchUpInside]; [unheartButton setBackgroundImage:[UIImage imageNamed:@"redheart.png"] forState:UIControlStateNormal]; imageView = [[UIImageView alloc] init]; imageView.frame = CGRectMake(12, 13, 16, 16); NSMutableArray *array = [[NSMutableArray alloc] init]; for (int ndx = 1; ndx < 13; ndx++) { [array addObject:[UIImage imageNamed:[NSString stringWithFormat:@"icon-loading-%d (dragged).tiff", ndx]]]; } imageView.animationImages = array; imageView.animationDuration = 1; imageView.hidden = YES; [array release]; [self.contentView addSubview:imageView]; [self.contentView addSubview:unheartButton]; return self; } } Button click: - (IBAction) onButtonClick: (id) sender { unheartButton.hidden = YES; imageView.hidden = NO; [imageView startAnimating]; [self setNeedsDisplay]; [self.contentView setNeedsDisplay]; [self.unheartButton setNeedsDisplay]; [self.imageView setNeedsDisplay]; } I'm calling setNeedsDisplay on everything, but nothing seems to happen. If I scroll off the screen and back up, the button is hidden and now the loading icon is shown, but this only happens after a scroll. I'm not sure what I need to do to get the cell to repaint.

    Read the article

  • UIScrollView imageViewDidEndZooming not being called

    - by Jorge
    I have this subclass of UIScrollView: @interface MyScrollView : UIScrollView <UIScrollViewDelegate> And I have those delegate methods - (void)scrollViewDidEndZooming:(UIScrollView *)aScrollView withView:(UIView *)view atScale(float)aScale{ NSLog(@"zoomed"); } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)aScrollView{ NSLog(@"willzoom"); } When I zoom in MyScrollView viewForZoomingInScrollView is called but scrollViewDidEndZooming never gets called. Any idea why??

    Read the article

  • Search and display buisness locations on MKMapView

    - by jmurphy
    Hello, I'm trying to find a way to search for a business, such as "grocery stores" and display them on a google map around the users current location. This used to be pretty simple with the old URL style of launching the apple map location but I can't find out how to do it with the MKMapView. I understand that I'll need to use the MKAnnotations classes but my problem is with finding the data. I've tried plugging in the URL below to get the info from google but the size of the data seems way too large. http://maps.google.com/maps?q=grocery&mrt=yp&sll=37.769561,-122.412844&z=14&output=kml Is there an easy way to just set a property that tells the MKMapView to search for a keyword and display all matching business around my current location? Or does anybody know how to get this information from google?

    Read the article

  • Notifying view controller when subview touch events occur.

    - by Nebs
    I have a UIViewController whose view has a custom subview. This custom subview needs to track touch events and report swipe gestures. Currently I put touchesBegan, touchesMoved, touchesEnded and touchesCancelled in the subview class. With some extra logic I am able to get swipe gestures and call my handleRightSwipe and handleLeftSwipe methods. So now when I swipe within the subview it calls its local swipe handling methods. This all works fine. But what I really need is for the handleRightSwipe and handleLeftSwipe methods to be in the view controller. I could leave them in the subview class but then I'd have to bring in all the logic and data as well and that kind of breaks the MVC idea. So my question is is there a clean way to handle this? Essentially I want to keep my touch event methods in the subview so that they only trigger for that specific view. But I also want the view controller to be informed when these touch events (or in this case swipe gestures) occur. Any ideas? Thanks.

    Read the article

  • How to convert a UTC date to NSDate?

    - by Sheehan Alam
    I have a string that is UTC and would like to convert it to an NSDate. static NSDateFormatter* _twitter_dateFormatter; [_twitter_dateFormatter setFormatterBehavior:NSDateFormatterBehaviorDefault]; [_twitter_dateFormatter setDateFormat:@"EEE MMM dd HH:mm:ss ZZZ yyyy"]; [_twitter_dateFormatter setLocale:_en_us_locale]; NSDate *d = [_twitter_dateFormatter dateFromString:sDate]; When I go through the debugger *d is nil even though sDate is "2010-03-24T02:35:57Z" Not exactly sure what I'm doing wrong.

    Read the article

  • UILabel: vertical alignment

    - by Stefan
    Hi, I have an UILabel with two lines. Sometimes it's text is short. Then the text gets displayed in the center (vertically) of the UILabel. How do I align my text at the top (vertically)? Regards...

    Read the article

  • How do I change the frame position for a custom MKAnnotationView?

    - by andrei
    I am trying to make a custom annotation view by subclassing MKAnnotationView and overriding the drawRect method. I want the view to be drawn offset from the annotation's position, somewhat like MKPinAnnotationView does it, so that the point of the pin is at the specified coordinates, rather than the middle of the pin. So I set the frame position and size as shown below. However, it doesn't look like I can affect the position of the frame at all, only the size. The image ends up being drawn centered over the annotation position. Any tips on how to achieve what I want? MyAnnotationView.h: @interface MyAnnotationView : MKAnnotationView { } MyAnnotationView.m: - (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]) { self.canShowCallout = YES; self.backgroundColor = [UIColor clearColor]; // Position the frame so that the bottom of it touches the annotation position self.frame = CGRectMake(0, -16, 32, 32); } return self; } - (void)drawRect:(CGRect)rect { [[UIImage imageNamed:@"blue-dot.png"] drawInRect:rect]; }

    Read the article

  • Custom annotationView images revert to pins when clicked

    - by Danny Tuppeny
    I'm displaying custom images on a map (instead of the default pins) using the code below. However, when I tap on an item (and the callout appears), the image reverts to the default red pin. How can I keep my custom image, even when the callout is displayed? - (MKAnnotationView *) mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation { MKPinAnnotationView *pinAnnotation = nil; if (annotation != mapView.userLocation) { static NSString *pinID = @"mapPin"; pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pinID]; if (pinAnnotation == nil) pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pinID] autorelease]; // Set the image pinAnnotation.image = [UIImage imageNamed:@"TestIcon.png"]; // Set ability to show callout pinAnnotation.canShowCallout = YES; // Set up the disclosure button on the right side UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; pinAnnotation.rightCalloutAccessoryView = infoButton; [pinID release]; } return pinAnnotation; [pinAnnotation release]; }

    Read the article

  • Delete a photo from the user's photo library?

    - by Jacob Relkin
    Hi, Is there a way I can delete an image that is loaded into my app from a UIImagePickerController? I want to be able to delete the image from the user's photo library when the user performs a specific action. I am prompting the user to choose a image from their library, then it gets loaded into my app at which point the app does some shnazzy animation, then actually deletes the image. Please help!

    Read the article

  • Delay in playing sounds using AVAudioPlayer

    - by iSharreth
    -(IBAction)playSound{ AVAudioPlayer *myExampleSound; NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@"myaudiofile" ofType:@"caf"]; myExampleSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:myExamplePath] error:NULL]; myExampleSound.delegate = self; [myExampleSound play]; } I want to play a beep sound when a button is clicked. I had used the above code. But it is taking some delay in playing the sound. Anyone please help.

    Read the article

  • Sqlite3 query in objective c

    - by user271753
    -(IBAction)ButtonPressed:(id)sender { const char *sql = "SELECT AccessCode FROM UserAccess"; NSString *sqlns; sqlns = [NSString stringWithUTF8String:sql]; if([Password.text isEqual:sqlns]) { NSLog(@"Correct"); } else { NSLog(@"Wrong"); } NSLog(@"%@",sqlns); } Noob here , At NSLog I am able to print "SELECT AccessCode FROM UserAccess" where as let say the access code is 1234 , which I want . In the appdelegate I Have : /// - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after app launch [self createEditableCopyOfDatabaseIfNeeded]; [window addSubview:viewController.view]; [window makeKeyAndVisible]; return YES; } /// - (void)createEditableCopyOfDatabaseIfNeeded { NSLog(@"Creating editable copy of database"); // First, test 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:@"UserAccess.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:@"UserAccess.sqlite"]; success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error]; if (!success) { NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]); } } /// +(sqlite3 *) getNewDBConnection{ sqlite3 *newDBconnection; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"UserAccess.sqlite"]; // Open the database. The database was prepared outside the application. if (sqlite3_open([path UTF8String], &newDBconnection) == SQLITE_OK) { NSLog(@"Database Successfully Opened :) "); } else { NSLog(@"Error in opening database :( "); } return newDBconnection; } Please help :(

    Read the article

  • UIImage color changing?

    - by senthilmuthu
    hi, how can i change the UIImage's Color through Programming,any help pls?if i send UIImage, its color must be changed ..any help please? if i change rgb color like the following through bitmaphandling it did not work.i have given blackcolor's RGB value like 0,0,0.....

    Read the article

  • How to detect changes to Address Book after ABPersonViewController presentation

    - by nkhorman
    I have two view controllers that allow changes to the Address Book. The first one lets you add or create an entry based on an ABRedordRef or edit an existing ABRecordRef, by presentation of either ABUnknownPersonViewController or ABPersonViewController. The second one is a standard ABPeoplePickerNavigationController that allows you to view/edit any of the contents of the Address Book. Both views are accessible easily accessible to the use via the main application UITabBarController. How can I determine that changes were made by either view controller, so that I can force data dependency changes to a third separate view controller. I thought that I saw a notification center message that I could subscribe to, but I can't seem to find it again... I don't care if the notification center is the method that should be used, or a delegate protocol or... whatever, I don't care, I just need to know how to detect the change or the need to re-sync with the Address Book. Can someone Please point me in the right direction. Thank you.

    Read the article

  • Application with two UITabBarControls

    - by kovpas
    Hello, I want to create an app, whith the following structure: UITabBarController ..UINavigationController ....UITabBarController So, in other words, I want to load first UITabbarController as my main ViewController, that appears on application start, in its' first tab there's a UINavigationController with a table, which shows another UITabBarController by pressing on a table cell. I started Tab Based application, set first tab to UINavigationController, and its ViewController to my TableViewController. I also created second UITabBarController in Interface Builder. Created a separate class for this controller. Everything works fine at start - my first UITabBarController is shown perfectly, but when I'm trying to push my second UITabBarController, using my UINavigationController, it looks like nothing is loaded from a .xib file - there are just an empty TabBar and NavigationBar pushed. Seems, that something is wrong with an architecture, but I can't figure out the problem. Thanks in advance and I'm sorry for my poor English. Please let me know if something is not clear, I'll try to rephrase it :).

    Read the article

  • cannot convert 'b2PolygonShape' to 'objc_object*' in argument passing

    - by GONeale
    Hey there, I am not sure if many of you are familiar with the box2d physics engine, but I am using it within cocos2d and objective c. This more or less could be a general objective-c question though, I am performing this: NSMutableArray *allShapes = [[NSMutableArray array] retain]; b2PolygonShape shape; .. .. [allShapes addObject:shape]; and receiving this error on the addObject definition on build: cannot convert 'b2PolygonShape' to 'objc_object*' in argument passing So more or less I guess I want to know how to add a b2PolygonShape to a mutable array. b2PolygonShape appears to just be a class, not a struct or anything like that. The closest thing I could find on google to which I think could do this is described as 'encapsulating the b2PolygonShape as an NSObject and then add that to the array', but not sure the best way to do this, however I would have thought this object should add using addObject, as some of my other instantiated class objects add to arrays fine. Is this all because b2PolygonShape does not inherit NSObject at it's root? Thanks

    Read the article

  • How to tell a rightCalloutAccessoryView has been touched for MapKit

    - by iamdadude
    I have a MKAnnotationView being allocated with a DetailDisclosure button being displayed on the right side of the annotation. How would I go about knowing when a user clicked on the annotation button? This is what my code looks like right now - UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; pinView.rightCalloutAccessoryView = rightButton; pinView.animatesDrop = YES; Is there a built in method to detect when a accessory view has been touched? I'm guessing it would be like the UITableView methods, but I can't find anything. Thanks for any help.

    Read the article

  • Creating a common selector class with UITableView or UIPicker

    - by trevrosen
    I have several places in my app where I need to select a Foo for further processing from a list of Foo objects. I'd like to do this as a modal view, but neither UIPicker nor UITableView seems to lend itself to the standard approach, since the usual way to do a modal view controller involves setting the parent view controller up as the delegate, and both of those classes need to implement data source protocols, etc. Implementing the data source and selection protocol methods in my parent view controller defeats the purpose of trying to use one common class for implementing this modal selector screen all over my app. Does anyone have any solutions to this problem or am I effectively stuck implementing this selector class over and over again?

    Read the article

  • Finding out estimated duration of a stream using Core Audio

    - by Reflog
    I am streaming a MP3 over network using custom feeding code, not AVAudioPlayer (which only works with URLs) using APIs like AudioFileStreamOpen and etc. Is there any way to estimate a length of the stream? I know that I can get a 'elapsed' property using: if(AudioQueueGetCurrentTime(queue.audioQueue, NULL, &t, &b) < 0) return 0; return t.mSampleTime / dataFormat.mSampleRate; But what about total duration to create a progress bar? Is that possible?

    Read the article

  • Turn a page (a UIWebView) with an animation

    - by Stefan
    Hi, I have a webview, which shows the pages of a ebook. I want to switch from one page to the next page with a page curl animation. By now, I'm know how to switch the page and how to apply a page curl animation on the webview. But how do I apply the curl animation in a way that it looks like flipping from one page to another?

    Read the article

  • Timeout a NSThread after a certain amount of time

    - by Zen_silence
    Hello, I have a NSThread that i would like to timeout after a certain amount of time. [NSThread detachNewThreadSelector:@selector(someFuntion) toTarget:self withObject:nil]; - (void) someFunction { //Some calculation that might take a long time. //if it takes more then 10 seconds i want it to end and display a error message } Any help you can provide on this would be greatly appreciated. Thanks, Zen_silence

    Read the article

  • Using kEAGLRenderingAPIOpenGLES2 causes bad access in glMatrixMode

    - by hyn
    I am trying to use the ES 2 API in my app but using kEAGLRenderingAPIOpenGLES2 causes bad access at glMatrixMode(). There is a similar question here but doesn't answer my question. If I use kEAGLRenderingAPIOpenGLES1 then everything is fine. I could reproduce the same problem with Apple's sample code. What can I do to make glMatrixMode() work in ES 2?

    Read the article

  • Asynchronous callback for network in Objective-C Iphone

    - by vodkhang
    I am working with network request - response in Objective-C. There is something with asynchronous model that I don't understand. In summary, I have a view that will show my statuses from 2 social networks: Twitter and Facebook. When I clicked refresh, it will call a model manager. That model manager will call 2 service helpers to request for latest items. When 2 service helpers receive data, it will pass back to model manager and this model will add all data into a sorted array. What I don't understand here is that : when response from social networks come back, how many threads will handle the response. From my understanding about multithreading and networking (in Java), there must have 2 threads handle 2 responses and those 2 threads will execute the code to add the responses to the array. So, it can have race condition and the program can go wrong right? Is it the correct working model of iphone objective-C? Or they do it in a different way that it will never have race condition and we don't have to care about locking, synchronize? Here is my example code: ModelManager.m - (void)updateMyItems:(NSArray *)items { self.helpers = [self authenticatedHelpersForAction:NCHelperActionGetMyItems]; for (id<NCHelper> helper in self.helpers) { [helper updateMyItems:items]; // NETWORK request here } } - (void)helper:(id <NCHelper>)helper didReturnItems:(NSArray *)items { [self helperDidFinishGettingMyItems:items callback:@selector(model:didGetMyItems:)]; break; } } // some private attributes int *_currentSocialNetworkItemsCount = 0; // to count the number of items of a social network - (void)helperDidFinishGettingMyItems:(NSArray *)items { for (Item *item in items) { _currentSocialNetworkItemsCount ++; } NSLog(@"count: %d", _currentSocialNetworkItemsCount); _currentSocialNetworkItemsCount = 0; } I want to ask if there is a case that the method helperDidFinishGettingMyItems is called concurrently. That means, for example, faceboook returns 10 items, twitter returns 10 items, will the output of count will ever be larger than 10? And if there is only one single thread, how can the thread finishes parsing 1 response and jump to the other response because, IMO, thread is only executed sequently, block of code by block of code

    Read the article

  • Change (not init) a UIBarButtonItem identifier programatically?

    - by Nebs
    In IB I can set the identifier of a UIBarButtonItem to 'play' which adds an image of a play button (right-pointing triangle). Is there a way to change this image programatically? I want to change it to 'pause' when the play button is pressed. I know you can initialize a UIBarButtonItem with an identifier but I've yet to find a way to change it after it's been initialized. Is this even possible? The only thing I can think of is to remove the old button and initialize a new one in its place, but this hardly seems efficient. Any thoughts?

    Read the article

< Previous Page | 149 150 151 152 153 154 155 156 157 158 159 160  | Next Page >